加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

调试器中如何使用perl 5.10功能?

发布时间:2020-12-15 21:33:38 所属栏目:大数据 来源:网络整理
导读:我无法评估Perl调试器中的“现代perl”代码.调试文件中的代码但不是提示时,它可以正常工作. 最小例子: # activating 5-10 features with -E (it works)$ perl -E 'say "x"'x # calling the debugger with -E# it works for infile code but for prompt line
我无法评估Perl调试器中的“现代perl”代码.调试文件中的代码但不是提示时,它可以正常工作.

最小例子:

# activating 5-10 features with -E (it works)
$ perl -E 'say "x"'
x
# calling the debugger with -E
# it works for infile code but for prompt line code...
$ perl -dEbug    Loading DB routines from perl5db.pl version 1.33
    DB say "x"
    String found where operator expected at (eval 16)[/local-perl/lib/5.12.1/perl5db.pl:638] line 2,near "say "x""
    at (eval 16)[/local-perl/lib/5.12.1/perl5db.pl:638] line 2
        eval '($@,$!,$^E,$,$/,$,$^W) = @saved;package main; $^D = $^D | $DB::db_stop;say "x";

[注意:与“使用功能”相同:5.10’“]

我错过了什么吗?

解决方法

这是一个有趣的问题,一个我从来没有想过的,所以就这么认为.

我发现参考这个问题here,但大约一岁.但是,perl源的相关部分并没有改变,可以看出here.基本上,如果您在perl源代码中查看toke.c,您将看到以下内容:

if (PL_perldb) {
    /* Generate a string of Perl code to load the debugger.
     * If PERL5DB is set,it will return the contents of that,* otherwise a compile-time require of perl5db.pl.  */

    const char * const pdb = PerlEnv_getenv("PERL5DB");
            ...
}
...
if (PL_minus_E)
    sv_catpvs(PL_linestr,"use feature ':5." STRINGIFY(PERL_VERSION) "';");

基本上,在处理-E标志之前加载调试器,因此当调试器加载时,功能尚未启用.这一点的主要目的是您现在无法使用-d命令使用-E.如果要使用说明,开关或任何其他功能从调试提示符,您必须这样做:

DB<1> use feature 'say'; say "x"
  x

我见过最近的一个解决方案是:

  1. copy perl5db.pl from your PERL5LIB to either somewhere in PERL5LIB or the current directory,with a different name,say myperl5db.pl
  2. Edit myperl5db.pl to have use feature ‘:5.10’; (or just ‘state’,or just ‘say’) on the first line.
  3. Set the environment variable PERL5DB to “BEGIN { require ‘myperl5db.pl’ }”

我发现在PerlMonks.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读