You could either redirect all STDERR output to a file, or pass all error
info to a sub routine. For the second method you could do...

if (system ($cmd)) {
  &fatalError("Error $!\n");
}  

sub fatalError {
    my $error = shift;
    open ERROR ">>error.txt" or die "Can't append to error.txt: $!";
    print ERROR $error;
    close ERROR;
    die "\n";
}

John


-----Original Message-----
From: Shishir K. Singh [mailto:[EMAIL PROTECTED]] 
Sent: 13 May 2002 17:04
To: [EMAIL PROTECTED]
Subject: Logging details


Is there a better way of logging the details in a file. 

E.g. 

I would like the error message to go into a file instead of going to the
stderr

if (system ($cmd)) {
  die "Error $!\n";
}  



I don't want to code the above as 

open (LOG,"> $logFile");
if (system ($cmd)) {
  print LOG "Error $!\n";
  die;
}  


Any pointers!! 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to