in reply to Trying to track a sleeping CGI request with gdb

As far as the OS is concerned, the running program is perl, and your script is just an argument to it. So you would do:
gdb /usr/bin/perl 1234

But this is doing to drop you into the middle of a running perl process, and you may not find that very helpful. It's easy enough to write a test script that will sleep for long enough that you can attach to it and poke around in the debugger. That should give you an idea of how to get around in the debugger, and whether or not you'll find this useful.

Ideally, you would want to drop into perl -d, but that currently isn't possible; see How to attach a perl debugger to a running perl.

I usually debug these sorts of things by printing out a lot of debugging information. Then when it's stuck, you can see the last thing it printed out to figure out what it's doing. As others have mentioned, strace/truss can also be very useful.