简体   繁体   中英

Why do I get .perldb alias syntax error when trying to display source?

I would like to display whole source code of perl script. Following line was added to .perldb:

$DB::alias{'code'} = 'l 1+99999;';

the .perldb chmod is set to 700. After issuing my alias I get following error:

  DB<1> code
Number found where operator expected at (eval 8)[/usr/share/perl5/perl5db.pl:2312] line 1, near "l 1"
    (Do you need to predeclare l?)
Couldn't evaluate `code' alias: syntax error at (eval 8)[/usr/share/perl5/perl5db.pl:2312] line 1, near "l 1"

alias seems to be loaded correctly:

  DB<2> =
code    l 1+100;

EDIT : When I define alias using '=' command it works as expected:

 DB<2> = code l 1+99999
shcd    = l 1+99999

  DB<3> =
code    l 1+99999

what I am doing wrong?

You have to declare the alias code and remove that content with the command you want to run. So inside the .perldb do a substitution command to get it, like:

$DB::alias{ 'code' } = 's/^.*$/l 1+99999/';

And then in the debugger use:

DB<100> code

And it will output the whole code of the script (if has less lines that one hundred thousand :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM