#!/usr/bin/perl use strict; use warnings; use Benchmark qw/cmpthese/; my $count = 100; cmpthese( $count, { 'line' => sub { my $f1; open( $f1, "< file" ); while ( my $l = <$f1> ) { push( my @ll, $l ); } close($f1); }, 'all' => sub { my $f1; open( $f1, "< file" ); my @ll = <$f1>; close($f1); } } );