Adding a standard Perl file open function to each script I have is a bit annoying:
sub openfile{ (my $filename) = @_; open FILE,\"$filename\" or die
I would recommend an object oriented approach that does not requires modules outside the CORE distribution and will work anywhere:
use strict; use warnings; use IO::File; my $fh = IO::File->new("< $file"); foreach ($fh->getlines) { do_something($_); } $fh->close