Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: In the art of Perl Debugger Mastery, I seek enlightenment

by chrestomanci (Priest)
on Feb 09, 2011 at 22:17 UTC ( #887306=note: print w/replies, xml ) Need Help??

in reply to In the art of Perl Debugger Mastery, I seek enlightenment

That is an open ended question if ever I saw one. In short, yes it is worth learning the perl debugger.

One of the very cool features of the perl debugger, that you tend not to find in flashy GUI debuggers found in expensive IDEs for compiled languages is the ability to try out stuff, and evaluate bits of code to see what happens.

For example, earlier today, a foolish monk posted their homework question (or may been it was a test). Because I was mildly interested, I started the perl debugger by typing perl -demo into a handy shell prompt. (A trick I learnt here, I think from chromatic). This got me a perl shell into which I typed:

x \{ split /[:;]/, "1:one;2:two;3:three" }

This confirmed that I had the correct syntax for the solution. Quick and easy. No need to write a script, save it into a file and print the output.

The ability to evaluate expressions is even more powerful when you are working on a big program. Frequently when I am using DBIx::Class or HTML::TreeBuilder, I will set a breakpoint in the script. (Add the line DB::single=1), and then start evaluating expressions to see where they lead. Once I have something useful, I paste it into my editor and go from there. You can do the same with complex regular expressions.

There are plenty more tips on how to use the debugger. Many can be found here if you search.

The other useful tip, is that many of the more senior monks in this monastery often keep lots of useful links on their home nodes, so if you have some free time, head over to Saints in our Book, and start clicking through to home nodes and see what you find. You may strike gold.

Replies are listed 'Best First'.
Re^2: In the art of Perl Debugger Mastery, I seek enlightenment
by Tommy (Chaplain) on Feb 15, 2011 at 14:11 UTC

    The -demo mnemonic is great! I often run perl -e, but combining the power of -e and -d is *awesooome*.

    This one goes into my treasure trove of perl hackery. HAHA! Wo0T!


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://887306]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2020-08-07 09:19 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (43 votes). Check out past polls.