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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With