Starting and Running the Debugger

Perl's built-in debugger is run from the command line using the -d option. If you've been running your Perl scripts on Unix or Windows NT using just the name of the script, you'll need to call Perl explicitly, with the name of the script and any filename arguments after that. In other words, if you usually call a script like this:

% names.txt

Call it like this for the debugger:

% perl
						-d names.txt

Alternately, if you think you'll be using the debugger a lot for a particularly gnarly script, you can add the -d option to the shebang line in the script itself:

#!/usr/ bin/perl –wd


Don't forget to remove it again when you're done debugging.

To turn on the debugger in MacPerl, choose ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.