use strict; use warnings; use Benchmark 'cmpthese'; my %subs = ( list_io => sub { # Second time round this will take # a loooooong time. my $file=$0; my @line; open my($fh), $file; @line= <$fh>; close($fh); return \@line; }, split_slurp => sub { my $file=$0; my @line; local $/; open my($fh), $file; @line=split /\n/,<$fh>; close($fh); return \@line; }, while_io => sub { my $file=$0; my @line; open my($fh), $file; push @line,$_ while <$fh>; close($fh); return \@line; }, ); cmpthese -5,\%subs; __END__