sub fred { # Lexical $fh is known from point of declaration (next line) to end of scope open(my $fh, "<", "f.tmp") or die "open error f.tmp: $!"; # ... process file here # We assume no references to $fh are created in and returned from this sub # (if you did that reference count of $fh would not be zero on sub exit) # ... die might be called ... (that's ok, can be caught via block eval) # ... there can be multiple return statements ... return; }