in reply to (ar0n) Re: Filehandles and Arrays
in thread Filehandles and Arrays
Nice! Or, less flashy, you can just put your fav'rit routine into a sub that takes a filename as argument.
sub slurp { my $filename = shift; open HEYNONNYNO, $filename or die "Can't open $filename: $!\n"; my @stuff = <HEYNONNYNO>; close HEYNONNYNO; [ @stuff ] }
And you call it with my @lines = @{slurp("foo.txt.")}; Added the code tags to make that look better.
Again, just for fun (I'm into that today).
|
|---|