I'd like to point out that these aren't really closures...The read_row function is a closure, it just happens to be a non-encapsulated closure as process can also see @indexes. It would act as a more effective closure if it was re-structured like so
use Symbol; { my @indexes = qw (3 0 4 5 6 7); my $fh = gensym; open $fh,"<my.dat" or die "my.dat: $!"; sub read_row { my $row = <$fh>; close $fh and return unless defined($row); return (split(/\s+/,$row))[@indexes]; } }
_________
broquaint
In reply to Re: Re: Closures and callbacks...
by broquaint
in thread Closures and callbacks...
by rdfield
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |