Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

I like Python's interactive shell a lot better than Perl's debugger. What are my alternatives?

by Anonymous Monk
on Jan 08, 2010 at 16:58 UTC ( #816352=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

A lot of discussion has been given to marketing Perl better recently in light of its perceived unpopularity as a dynamic language relative to Python - for me one thing that's always stood out is the slightly-more-difficult process of testing small code concepts. With Perl it's often easier to just crank out a new test script, write it and run it - but I often just delete these later and rarely go back and look at them once I've grasped what I intended to.

If it's small enough I can use Perl's debugger (perl -de 1) in interactive mode, but this has several disadvantages to Python's shell:

  • Line continuation must be done explicitly with \ (making it more tedious to copy-paste code)
  • Typing a variable doesn't do anything - you have to know to type print first (or p if you've read the help). You also don't get the introspection Python gives for functions or objects.
  • My Ubuntu Perl shell doesn't have readline support
  • Having to explicitly turn on strict and warnings

Having said all this I echo much of this RFC request but still, to me this issue doesn't get enough attention in the discussion of the perception of poor Perl adoption - in addition to selfishly wanting what I can get in Python in my Perl coding tasks.

Comment on I like Python's interactive shell a lot better than Perl's debugger. What are my alternatives?
Select or Download Code
Re: I like Python's interactive shell a lot better than Perl's debugger. What are my alternatives?
by zentara (Archbishop) on Jan 08, 2010 at 17:07 UTC
    I always use the Tk graphical user interface to the Perl debugger..... see Devel-ptkdb..... google for many tutorials

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
Re: I like Python's interactive shell a lot better than Perl's debugger. What are my alternatives?
by roboticus (Chancellor) on Jan 08, 2010 at 17:13 UTC
Re: I like Python's interactive shell a lot better than Perl's debugger. What are my alternatives?
by Corion (Pope) on Jan 08, 2010 at 17:14 UTC

    Also see Perl::Shell, which tries to be what the Python shell is, but with Perl.

Re: I like Python's interactive shell a lot better than Perl's debugger. What are my alternatives?
by almut (Canon) on Jan 08, 2010 at 17:39 UTC
    • My Ubuntu Perl shell doesn't have readline support

    Installing the package libterm-readline-gnu-perl should get you readline support.

    BTW, while looking up the exact package name (i.e. apt-cache search readline | grep perl), I accidentally also found perlconsole.  Maybe that's another one for you to try out...

    $ apt-cache show perlconsole ... Description: small program that lets you evaluate Perl code interactiv +ely Perl Console is a light program that lets you evaluate Perl code interactively. It uses Readline for grabing input and provides comple +tion with all the namespaces loaded during your session. . This is pretty useful for Perl developers that write modules. You can load a module in your session and test a function exported by + the module.

    (I'm not a big fan of REPLs myself (prefer to have code in my editor), so I can't comment on its usefulness.)

Re: I like Python's interactive shell a lot better than Perl's debugger. What are my alternatives?
by talexb (Canon) on Jan 08, 2010 at 17:39 UTC

    I'm probably showing my age when I write this (I was born in the late 50's), but the Perl debugger is fine for me -- but then, I've used a variety of debug monitors and IDEs in my career, this one just has a variety of different commands for the same things that I want to do.

    I use the debugger for small things I want to try out, and occasionally for tracking down a more complex problem. That's my way of saying it might be faster (with regard to your two points about line continuations and readline support suggest that) just to write a one-time script and step through it in the debugger.

    As far as learning you have to type print $x or x $x, I'm guessing you haven't spent that much time useing the debugger. If you had, you'd know how to

    • set a breakpoint (b);
    • run (c);
    • step through code (n);
    • step down into a function (s);
    • dump values (x); and
    • quit (q).

    Once you've got those basics down, you can get into more esoteric things, such as running until a variable is equal to a specific value, clearing breakpoints (B, I think) and so forth.

    If you're keen to improve the Perl debugger, remember, this is open source -- feel free to jump in and help out.

    Alex / talexb / Toronto

    Team website: Forex Chart Monkey, Forex Technical Analysis and Pickpocket Prevention

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: I like Python's interactive shell a lot better than Perl's debugger. What are my alternatives?
by Kirsle (Pilgrim) on Jan 08, 2010 at 22:41 UTC
    If you want to run a quick Perl script without having to create & write in a file, you can run `perl` by itself and enter your code. End it with __END__ on its own line, or Ctrl-D, and then it will run what you've input.

    I prefer ending with __END__ because then you can copy/paste the code and its output and see easily where the code ends and the output begins.

    [kirsle@damocles ~]$ perl print "Hello world!\n"; use Digest::MD5 qw(md5_hex); for (1..5) { print "$_ => " . md5_hex($_) . "\n"; } __END__ Hello world! 1 => c4ca4238a0b923820dcc509a6f75849b 2 => c81e728d9d4c2f636f067f89cc14862c 3 => eccbc87e4b5ce2fe28308fd9f2a7baf3 4 => a87ff679a2f3e71d9181a67b7542122c 5 => e4da3b7fbbce2345d7772b0674a318d5 [kirsle@damocles ~]$

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://816352]
Approved by bingos
Front-paged by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2015-07-04 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls