use IO::File; { my $fh = IO::File->new('foo', 'r'); # do something with $fh } # The file handle has been automagically closed!