in reply to To Debug a Hanging Perl Script

If you're on Linux, use the strace utilitiy to tell you what your script is doing while it hangs. Either run

strace -f perl mycode.pl input_file.txt > output.txt

or start your script normally, wait till it hangs, find out the PID of the script process and execute

strace -f  -p <PID>

strace prints to STDERR, so you'll see the strace output normally in your terminal while STDOUT still gets written to the output file. It will tell you what the process is doing on a system call level. To find out where it hangs at the perl level you could execute it in the debugger and step through until it hangs.

perl -d mycode.pl input_file.txt > output.txt

All dogma is stupid.

Replies are listed 'Best First'.
Re^2: To Debug a Hanging Perl Script
by Fletch (Bishop) on Mar 02, 2006 at 16:36 UTC

    Similar utilities for other platforms are ktrace and kdump for BSDen (including OS X), and truss for Solaris.

    They're all handy if you're really stumped, but go for tossing in a few debugging prints to STDERR and running with -d first.