Help for this page

Select Code to Download


  1. or download this
    sub my_sub {
        my $closed_handle = shift;
        die "For some reason our handle isn't closed yet."
            if $closed_handle->opened;
    }
    
  2. or download this
    close $fh or my_sub($fh);
    
    ...
        my $error = $handle->error;
        die "Got this error code: $error\n" if $error;
    }
    
  3. or download this
    # Open a handle only if it's not opened.
    sub my_sub {
        open $_[0], '<', $_[1] if !$_[0]->opened;
    }