Yep. Instead of checking the $? or $! I played a trick.This code sinppet inside a function.
my $status = `gzip -cd filename 2>&1`;
print "The status is:$status\n";
if (!($status eq ''))
print " ERROR : $file is corrupt. \n";
It works!!! But do you think this is the right way to tackle?
But problem is when I am trying to close a pipe handle. I did somethig like that:
my @command =qw(gzip -cd filename);
my $fh = new IO::Pipe;
$fh->reader(@command)|| warn "ERROR : Can't read : $!";
#doing some long job here;such as
$variable = readline $fh;
undef $fh;#close $fh
if ($? != 0)
print "problem in undef or closing:$? with status:$!";
I am getting the last print message as error as:problem in undef or closing:-1 with status:no child process". My question is that is it required to check the $? or $! here? If we ignore it will system dump core?