boat73 has asked for the wisdom of the Perl Monks concerning the following question:
#### Use cpprint in place of print #### cpprint("HELLO OUTPUT\n"); #### WARN STATEMENTS WILL BE WRITTEN TO STDOUT AND ERRFILE #### warn "HELLO ERR FILE"; #### DIE STATEMENTS WILL BE WRITTEN TO ERRFILE, SINCE DIE EXECUTES NO +MATTER WHAT IS IN THE INIT DIE STATEMENTS WILL GO TO STDERR ANYWAY ## +## die "HELLO DEATH\n"; INIT { my $outfile = "myoutfile.out"; my $errfile = "myerrfile.err"; open(ERRFILE,'>>', "$errfile") or die "Could not open error file $ +errfile $!\n"; open(OUTFILE,'>>', "$outfile") or die "Could not open error file $ +outfile $!\n"; $SIG{'__DIE__'} = \&ondie; $SIG{'__WARN__'} = \&onwarn; } END { close ERRFILE; close OUTFILE; } sub ondie { my $date = localtime(time); print ERRFILE "$date\t@_\n"; } sub onwarn { print "WARNING: @_\n"; my $date = localtime(time); print ERRFILE "$date\tWARNING: @_\n"; } sub cpprint{ my $date = localtime(time); print OUTFILE "$date\t@_"; print @_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trying to copy STDERR STDOUT on win32
by ww (Archbishop) on Aug 17, 2005 at 19:36 UTC | |
|
Re: trying to copy STDERR STDOUT on win32
by DrWhy (Chaplain) on Aug 17, 2005 at 21:44 UTC | |
by boat73 (Scribe) on Aug 18, 2005 at 12:55 UTC | |
by DrWhy (Chaplain) on Aug 18, 2005 at 15:31 UTC | |
by boat73 (Scribe) on Aug 18, 2005 at 16:55 UTC |