If you run your program with perl -d:Trace program, this module will print a message to standard error just before each line is executed, like sh -x.