On Jun 22, 2007, at 11:57 AM, 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.

Given those requirements, a simple solution would be:

  unless (m_flag_given) {
      open my $fh, '>>cronlog.txt' or die $!;
      select $fh;
  }

  # the rest of the program uses regular prints

-- fxn


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


Reply via email to