in reply to Closures as Itterators
The reason is because is purely habit. One day you will write your own classes, and they may use inheritance, which is where the other style will bit you. Tis a shame i think, because it just _looks_ so much nicer. ;)my $fh = IO::File->($datafile) or die; #instead of - and you don't need the quotes either my $fh = new IO::File "$datafile";
Now you don't need the last, and while(1) just looks evil. >:)while (<$fh>) { chomp; # use $_ instead of $row # etc . . .
Otherwise, nice i like it. Damian Conway discusses using closures to implement iterators in his awesome OO book. You can find a snippet at (jeffa) Re: Defining Arrays.
Jeff
R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Closures as Itterators
by blakem (Monsignor) on Jul 01, 2001 at 14:38 UTC | |
by dragonchild (Archbishop) on Jul 02, 2001 at 21:33 UTC | |
by blakem (Monsignor) on Jul 02, 2001 at 22:48 UTC | |
by dragonchild (Archbishop) on Jul 02, 2001 at 23:30 UTC | |
by blakem (Monsignor) on Jul 02, 2001 at 23:49 UTC |