Robert Hicks schreef:
> If I do this:
>
> open $FH, '<', $THE_FILE or die "$0: open problem";
> my @ids = map substr($_, 0, 5), <$FH>;
>
> Does that file handle get closed after the slurp?
No, but you can write it like:
#!/usr/bin/perl
use strict;
use warnings;
my $fname = q/data.txt/;
my @ids;
{
open my $fh, q/</, $fname or die qq/$0:$fname: $!/;
@ids = map substr($_, 0, 5), <$fh>;
close $fh;
}
That "close $fh" is implicit, so it can be left out.
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/