in reply to Debug openings and closings
open my $file, "<", $filename # use lexical variable open FILE, "<", $filename # use bareword.
The file will be closed at the end of the foo subroutine. If you want the file handle then return it.sub foo { my ($filename) = @_; open my $file, "<", $filename or die "blah :$!\n"; while (<$file>) { # etc } # explicit call to close not needed. }
|
|---|