Re: perl option
by Fletch (Bishop) on Jan 05, 2005 at 16:43 UTC
|
Try installing Devel::Trace and then use perl -d:Trace foo. That'll get you something similar to a shell's set -x functionality.
| [reply] [d/l] |
|
I just want to pipe up briefly in support of Devel::Trace.
It has a much lower learning curve than most of the other
suggestions and does precisely what Anonymous Monk asked for.
| [reply] |
|
the -d:Trace can go on a shebang line too.
| [reply] [d/l] |
Re: perl option
by qq (Hermit) on Jan 05, 2005 at 16:43 UTC
|
| [reply] [d/l] |
Re: perl option
by Popcorn Dave (Abbot) on Jan 05, 2005 at 17:03 UTC
|
You may want to try the Graphical Debugger. It's written in Perl/Tk and has saved my bacon numerous times.
You can watch your variables as your program executes - which is what I assume you wanted to do with the print statements you don't want to liberally sprinkle all across your program. The really nice thing is that you can also contract or expand arrays, hashes and complex data structures so you can see how they're being modified.
Good luck!
Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.
| [reply] |
Re: perl option
by hubb0r (Pilgrim) on Jan 05, 2005 at 20:24 UTC
|
perl -d script.pl
Takes a little learning to use the debugger.
There's a graphical debugger addon that I've recently been using that's (in my opinion) very useful, and fairly stable. Its Devel::ptkdb and is invoked via perl -d:ptkdb script.pl.
More info here: http://search.cpan.org/~aepage/Devel-ptkdb-1.1091/ptkdb.pm | [reply] |
Re: perl option
by techra (Pilgrim) on Jan 05, 2005 at 22:12 UTC
|
There's also a couple of other ways I've always found to be helpful in debugging perl scripts, especially since I mostly work in a web environment.
Setting a scalar (say $debug) to 1 or 0 at function call and having your print functions conditional on $debug being true.
( print "I'm here" if $debug ). Better yet, writing your own debug function that listens to some higher-level variable is also a great way to do it.
I also recommend the very nifty Smart::Comments from CPAN, which allows you to use specially formated # comments based on conditions, printed to the buffer.
| [reply] |
|
| [reply] |
Re: perl option
by neilwatson (Priest) on Jan 05, 2005 at 19:44 UTC
|
Never underestimate the use of print and die statements. They are simple but valuable during development.
| [reply] [d/l] [select] |
Re: perl option to trace execution
by mkirank (Chaplain) on Jan 06, 2005 at 05:51 UTC
|
| [reply] |
Re: perl option to trace execution
by DigitalKitty (Parson) on Jan 06, 2005 at 18:01 UTC
|
| [reply] |
Re: perl option to trace execution
by Anonymous Monk on May 12, 2016 at 01:44 UTC
|
Use the debugger's autotrace setting.
"perl -d foo.pl", then at the debugger prompt, turn on auto trace "o AutoTrace=1".
"c" to continue program execution and it will show each line as it is executed.
| [reply] |