I have a system script in perl. I need some equivalent of bash -x to determine what is going wrong with the script. Is there something equivalent?
EDIT: What bash -x does is that it prints each line as it is evaluated. This makes debugging code that is just missing some path variable or file very easy.
Take a look at
Devel::Trace
orDevel::ebug
.Given this program named
w.pl
:You can use
Devel::Trace
to watch the execution:Which produces the following output:
You should look at "perl -d" (turn on debugger) or "perl -c" (check your script before executing
The
Devel::DumpTrace
module has been available since 2011.Sample usage:
Always include these statements in your perl scripts:
If you want to debug it, use the
-d
switch. And here are the commands: http://www.domainavenue.com/pl-debug.htmHope that helps.