On Thu, 30 Aug 2007 10:32:01 +0100, Beginner wrote:
> I want all the output plus any error messages to got to a log file. I 
> used the BEGIN block to direct STDERR into the file:
> 
> BEGIN { 
>       open(STDERR, ">>/usr/local/myreports/report.log") || die "Can't 
> write to file: $!\n";
> }
> 
> use strict; 
> use warnings;
> ...
> ### Start some logging ###
> my $log;
> my $logfile = "$dist_dir/report.log";
> open($log,">>$logfile") || die "Can't write to $logfile: $!\n";
> print $log "$0 called at ", &tm," with pid $$\n";

Why are you using a BEGIN block?  Why not just make it the first
executable statement?  Do you have any other 'use' statements in the
program?

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to