Output perl debugger only to a file and not to the console

Viewed 52

(This is a followup to this question I asked recently)

I'm using the perl debugger non-interactively like this:

PERLDB_OPTS="NonStop=1 LineInfo=/path/to/perl_log AutoTrace=0" perl -d big_confusing_script.pl $some $args

But in addition to writing the output to the log, it's also printing these 100s of lines to the console, which makes it very hard to see whether or not changes i'm making are messing up the flow of the larger shell script this perl script is a part of, and thus making it hard to create an effective debug workflow.

I'd like to know if it's possible to get this debug info to only be logged to the file and not written to the console. Is this possible with another PERLDB_OPTS flag? Or do I have to redirect stderr to /dev/null when invoking perl or something? Note that for the tool to work, the Perl's normal printing to stdout needs to be unaffected.

1 Answers

You can direct STDOUT to a file like this:

perl program.pl > out.txt

And you can do the same for STDERR like this:

perl program.pl 2> err.txt

You can also use them together like this:

perl program.pl > out.txt 2> err.txt

Instead of using the Perl Debugger to output to the file, try:

PERLDB_OPTS="NonStop=1 AutoTrace=0" perl -d big_confusing_script.pl $some $args > /path/to/perl_log
Related