sub { my ($target, $table, $fieldstring, $comstr) = @_; my @cmd = ( mibtable => ( -table => $table, -fields => $fieldstring, -node => $target, ); open(my $fr_child, '-|', @cmd) or die("Can't launch $cmd[0]: $!\n"); while (<$fr_child>) { # do stuff } close($fr_child) or die("Can't wait for child: $!\n"); die("Child died from signal ", ($? & 0x7F), "\n") if $? & 0x7F; die("Child died with code ", ($? >> 8), "\n") if $? >> 8; print("Child exited successfully\n"); }