On Jun 22, 5:57 am, [EMAIL PROTECTED] (Ben Edwards) wrote:
> I am opening a log file:
>
> open( LOGFILE,  ">>cronlog.txt" );
>
> This is being written to in lots of places.
>
> I have been asked to change the program so if -m (manual) flag is
> passed the stuff that goes to the log file is send to standard out
> instead.  Is it possible to change the above command to redirect
> LOGFILE to STDOUT (i.e. make the two the same thing.
>
> i.e.
>
> if ( defined( $opt_m ) ) {
>   open( LOGFILE, STDOUT );} else {
>
>   open( LOGFILE,  ">>cronlog.txt" );
>
> }
>
> I even tried:
>
> LOGFILE = STDOUT;
>
> But I get:
>
> Bareword "STDOUT" not allowed while "strict subs" in use
>
> Whjenever I try to use STDOUT;(

Because this is the equivalent of saying
"LOGFILE" = "STDOUT";
which obviously makes no sense, so by using strict such things are
prevented.

You can however assign the typeglob *LOGFILE to *STDOUT:

if (defined( $opt_m) ) {
   *LOGFILE = *STDOUT;
}

Paul Lalli


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


Reply via email to