use IO::File; my $fh = IO::File->new('foo', 'r'); # do something with $fh undef $fh;