We Recommend

Learning Perl Learning Perl
In this smooth, carefully paced course, a leading Perl trainer teaches you to program in the language that threatens to make C, sed, awk, and the Unix shell obsolete for many tasks. This book is the "official" guide for both formal (classroom) and informal learning. It is fully accessible to the novice programmer.


Posted By

micmath on 07/27/07


Tagged

perl


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

mabridge


Redirect everything to log file.


Published in: Perl 


  1. $logfile = "/tmp/mylog.txt";
  2. open STDOUT, ">>", $logfile or die "cannot append to '$logfile': $!\n";
  3. open STDERR, ">&STDOUT" or die "cannot dup STDERR to STDOUT: $!\n";
  4. select STDERR; $| = 1;
  5. open LOG, ">&STDOUT" or die "cannot dup LOG to STDOUT: $!\n";
  6. select LOG; $| = 1;
  7. select STDOUT; $| = 1;

Report this snippet 

You need to login to post a comment.