简体   繁体   English

为什么在尝试显示源时出现.perldb别名语法错误?

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

I would like to display whole source code of perl script. 我想显示perl脚本的整个源代码。 Following line was added to .perldb: 将以下行添加到.perldb:

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

the .perldb chmod is set to 700. After issuing my alias I get following error: .perldb chmod设置为700。发出别名后,出现以下错误:

  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. 您必须声明别名code然后使用要运行的命令删除该内容。 So inside the .perldb do a substitution command to get it, like: 因此,在.perldb内部执行替换命令来获取它,例如:

$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 :-) 它将输出脚本的全部代码(如果行数少于十万,则为:-)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我使用“given”时为什么会出现语法错误? - Why do I get a syntax error when I use “given”? 当我尝试为mips64交叉编译libperl时,为什么会出现语法错误? - Why do I get a syntax error when I try to cross compile libperl for mips64? 当我想打印到哈希键中的句柄时,为什么会出现语法错误? - Why do I get a syntax error when I want to print to a handle in a hash key? 为什么在我的代码生成程序中出现此语法错误? - Why do I get this syntax error in my code generating program? 当我尝试打印包含带有冒号的键的嵌套哈希时,为什么会出现语法错误? - Why do I get a syntax error when I try to print a nested hash that has keys containing colons? 尝试将值插入具有“索引”列的表时,为什么会出现SQL语法错误? - Why do I get a SQL syntax error when I try to insert values into a table with a column named “index”? 在Perl中,为什么在尝试使用字符串eval时会出现语法错误? - In Perl, why do I get a syntax error when I try to use string eval? 尝试与Net :: Telnet进行匹配时,为什么会出现错误“ Unmatched(in regex”)? - Why do I get the error “Unmatched ( in regex” when trying to match something with Net::Telnet? 当我运行Perl单行代码时,为什么在意外的标记`(&#39;)附近出现“ -bash:语法错误”? - Why do I get “-bash: syntax error near unexpected token `('” when I run my Perl one-liner? 为什么在此Perl代码中出现“&#39;$ rocks [&#39;附近的语法错误””? - Why do I get “Syntax error near '$rocks['” in this Perl code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM