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
You have several options, the classic do method:
my @array = do {
open my $fh, "<", $filename
or die "could not open $filename: $!";
<$fh>;
};
The IO::All method:
use IO::All;
my @array = io($filename)->slurp;
The File::Slurp method:
use File::Slurp;
my @array = read_file($filename);
And probably many more, after all TIMTOWTDI.