This page contains some notes about the Perl programming language. We also have a page of useful PerlOneLiners.

Trace execution in a Perl script

Getting a trace showing each executed line of code in sequence (think sh -x but for Perl scripts) is not obvious. perl(1)'s -D switch itself does not provide such functionality, but you can get there like so:

$ PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS program

Another option is to install the Devel::Trace module and simply use it on the script using the -d:Trace argument:

$ perl -d:Trace program

This does not work everywhere, but is has the advantage that you can easily influence the amount of trace output from within the script. Perl developers will therefore probably prefer to use the module.