Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the disadvantages of using the Perl debugger vs a real REPL like Devel::REPL?

Tags:

debugging

perl

I usually use perl -de 42 for obtaining an interactive Perl shell. I have seen Devel::REPL and I have seen some blogs like http://www.xenoterracide.com/2010/07/making-repl-usable.html explaining how you can enhance Devel::REPL with the plugins, but I have not used yet.

Is it too bad to use the debugger as an interactive shell? Why?

Note: the disadvantages mentioned in this PerlMonks node were limitations of the user, not of the Perl debugger.

Where can I read more about Perl REPL?

Is Devel::REPL ready for the limelight?

UPDATE: I accepted the Pedro's answer because it answered the question that I asked, but still I would like to know when and why (if any) the use of the Perl debugger as an interactive shell is a bad idea compared with one of the Perl REPL implementations. And which Perl REPL do you prefer?

like image 212
Pablo Marin-Garcia Avatar asked Sep 07 '10 23:09

Pablo Marin-Garcia


2 Answers

One disadvantage of perl -d is that lexical variables immediately go out of scope. Example:

DB<1> my $p = 123;

DB<2> print $p;

DB<3>

From perldebug:

Note that the said eval is bound by an implicit scope. As a result any newly introduced lexical variable or any modified capture buffer content is lost after the eval. The debugger is a nice environment to learn Perl, but if you interactively experiment using material which should be in the same scope, stuff it in one linescope, stuff it in one line.

like image 93
Pedro Silva Avatar answered Nov 14 '22 22:11

Pedro Silva


Rather than use the debugger and miss out on features, I tend to use just

perl -wnE'say eval()//$@'

I've used Devel::REPL and like it, but just never got used to using it.

An advantage to using the debugger is being able to have $DB::single=1 to stop and single-step at a given point.

like image 41
ysth Avatar answered Nov 14 '22 21:11

ysth