[tpm] IO::Handle not catching errors
Madison Kelly
linux at alteeve.com
Mon May 26 12:45:45 PDT 2008
Hi all,
I use IO::Handle for shell calls, and then check 'error' to see if
there was an error. However, this isn't catching errors... Can someone
clue me in?
sub do_shell_call
{
my ($shell_call)=@_;
my $sc=IO::Handle->new();
print " Shell call: [$shell_call]\n";
open ($sc, $shell_call) or die "Shell call: [$shell_call] failed with
error: $!";
my $output=0;
while (<$sc>)
{
if (!$output) { print "/----\n"; $output=1; }
print "| $_";
}
if ($output) { print "\\----\n"; }
if ($sc->error)
{
die "Shell call: [$shell_call] returned an error: $!";
}
$sc->close;
return 0;
}
Madi
More information about the toronto-pm
mailing list