Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Using the Perl Debugger (-d)

by Moron (Curate)
on Jan 25, 2007 at 18:09 UTC ( [id://596584]=note: print w/replies, xml ) Need Help??


in reply to Using the Perl Debugger (-d)

I came from a C/Fortran/Pascal background too. During the first week I was learning Perl, (in 1999) a colleague told me to use perl -d for debugging and to then type h for a list of commands. So I learnt to use the debugger before I even knew what a hash was. I just can't imagine life without it. The "burning" features I use the most are:

- setting breakpoints to be able to go to the (sometimes complex) problem line and sit there examining all the pieces of the expression until I find the culprit.

- setting watchpoints so that when you don't know where the problem line is where you would be putting a printf, you can get the debugger to stop just before it is about to modify something, wherever that might be and print out the before and after values, giving you control back to look further.

- assigning values at different points to force the path of execution to get to where you need it rather than waiting for the program to follow its "natural" course, which could be hours or days in extreme cases.

- using CPAN and core modules, it is not always practical to put in print statements - the debugger is a lot easier than having to make modifications to code, it might also be dangerous to change published code you don't understand - and it can often be rather geeky!!

Update: I once had to work in an environment where no predecessor had ever used the debugger. Their heavy-handed but functionally useful logging routines made it impossible to use the debugger. This meant they had to spend a lot of time in the early life of the system resetting the situation at both ends of the system and re-running with logging calls, where the debugger could have reduced it to a single run.

-M

Free your mind

Replies are listed 'Best First'.
Re^2: Using the Perl Debugger (-d)
by Melly (Chaplain) on Jan 25, 2007 at 19:50 UTC

    Nice - this gives me some concepts to play with. If nothing else, I've learnt today (from reading the excerpt from the O'Reilly book that someone posted) that perl -de 0 is a much better environment for checking quick answers to questions posted or CB'd to perlmonks...

    map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
    Tom Melly, pm@tomandlu.co.uk

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-06-24 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.