This is annoying because I am also get used to use the debugger as a REPL (yes, I know Devel::REPL but I have not installed it everywhere and I usually have a perl debugger already open in my emacs).
After a lot of time avoiding the issue I asked it in stack overflow:
How to use perl 5.10 features inside the debugger?
and eldarerathis explained to me why
perl -dEbug
is not working:
[ eldarerathis]
I found a reference to the issue here, but it's about a year old. However, the relevant portion of the perl source hasn't changed since, and can be seen here.
Basically, the debugger is loaded before the
I found a reference to the issue here, but it's about a year old. However, the relevant portion of the perl source hasn't changed since, and can be seen here.
[...]
Basically, the debugger is loaded before the
-E
flag is processed, so the features aren't yet enabled when the debugger gets loaded. The gist of this is that you can't currently use -E
with the -d
command. If you want to use say
, switch
, or any other feature from the debug prompt, you have to do it like this:
DB<1> use feature 'say'; say "x"
x
Also seems that feature is lexically scoped so this does not work:
DB<19> use feature 'say'
DB<20> say 1
Number found where operator expected at (eval 41)[/homes/pmg/pmg-soft/local-perl/lib/5.12.1/perl5db.pl:638] line 2, near "say 1"
DB<20> say 1
Number found where operator expected at (eval 41)[/homes/pmg/pmg-soft/local-perl/lib/5.12.1/perl5db.pl:638] line 2, near "say 1"
but this does:
DB<21> use feature 'say';say 1
1
1
This is annoying because when debuggin perl >5.10 scripts, sometimes I need to fix a given/when, or a line with ~~ or copy-paste a line with say and it does not work :-(.
If someone has any idea how to use new Perl code features in the debugger command line please let me know or answer in stack overflow.
It is cheesy, but you can add whatever you want to line 23 of ebug/Backend/Plugin/Eval.pm. By adding "use 5.012;" I got it to work for me.
ReplyDeletemy $v = eval "package $context->{package}; use 5.012; $eval";
thanks Chas.
ReplyDelete