Come for the quick hacks, stay for the epiphanies. | |
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?? |
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
In Section
Seekers of Perl Wisdom
|
|