use strict; use Benchmark; sub test1 { open FILE,'<',$0 or die $!; local $/; print STDERR ; close FILE; } sub test2 { open FILE,'<',$0 or die $!; while () { print STDERR $_; } close FILE; } sub test3 { open my $fh,'<',$0 or die $!; local $/; print STDERR <$fh>; close $fh; } sub test4 { open my $fh,'<',$0 or die $!; while (<$fh>) { print STDERR $_; } close FILE; } ############################################### sub test5 { require IO::File; my $fh = IO::File->new($0,'r') or die $!; print STDERR <$fh>; $fh->close(); } timethese(1_000_000,{ 'Mit "open FILE" und ohne "while"' => \&test1, 'Mit "open FILE" und mit "while"' => \&test2, 'Mit "open $fh" und ohne "while"' => \&test3, 'Mit "open $fh" und mit "while"' => \&test4, 'Mit "IO::File"' => \&test5 });