http://www.perlmonks.org?node_id=509183


in reply to Neat Debugger tricks

Not so much a trick in the debugger, but I like to use it as an "interactive Perl shell", using a command like perl -de 1. Of course, any expression other than -e 1 will work, I'm just used to that one.

For example, if you're wondering whether a particular regex will match, or whether your split will work as you intended, but you don't want to mess around with shell quotes, just:

$ perl -de 1 Loading DB routines from perl5db.pl version 1.25 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): 1 DB<1> $s = '12345' DB<2> x split(/(?<=\d)/, $s) 0 1 1 2 2 3 3 4 4 5 DB<3> q # yup, it works
I believe I first read about this in Effective Perl Programming.

Replies are listed 'Best First'.
Re^2: Neat Debugger tricks
by siracusa (Friar) on Nov 17, 2005 at 13:22 UTC
    I've always used "perl -de 0", but the too-clever version used to impress or confuse people is "perl -demo" :)

      I like perl -deal. Or, since we’re on PerlMonks, maybe perl -deacon?

      (Another classic, though it has nothing to do with the debugger, is perl -please as a fun if expensive replacement for cat.)

      Makeshifts last the longest.

        Then I suppose Grandmother would like perl -dearie ???

        And those bioperl folks would choose perl -deoxyribonucleic acid ?

        And the anti-DRM crowd would go for perl -decss ??

        Archeologists: perl -decrypt

        And when everyone is tired of this, I'll be asked to perl -desist ;)

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of