in reply to Catch messages to STDERR
The following code catches all print operations on the STDERR file handle.
package ErrorTrapper;
sub TIEHANDLE{
my ($class, $file) = @_;
bless [] , $class;
}
sub PRINT{
my ($self, @msg) = @_;
die "@msg\n";
}
package main;
tie *STDERR, "ErrorTrapper";
print "Testing...\n\n";
print STDERR "Something went wrong!\n";
print "Shouldn't see this";
Cheers,John
|
|---|