close $fh or my_sub($fh); sub my_sub { my $handle = shift; my $error = $handle->error; die "Got this error code: $error\n" if $error; }