sub myfile { my $file = shift; open my $fh, $file or die "Couldn't open '$file': $!"; my @lines = <$fh>; close $fh or die "Couldn't close '$file': $!"; return \@lines; } # and call it like this: my @lines = @{myfile('xml.log')};
Update: If it's a bug as demerphq suspects, then I suspect that it's OS dependent - I get the same times here on all opens (perl v5.6.0 built for sun4solaris).
-- Hofmator
In reply to Re5: opening a file in a subroutine
by Hofmator
in thread opening a file in a subroutine
by abhishes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |