in reply to [stonehenge] deep copy what's the function getpwent()
In Perl, they're usually written using a closure:
sub make_iterator { my (@list) = @_; return sub { # return a false value if exhausted return unless @list; # return next item in list return shift @list; }; } my $iter = make_iterator(1..5); while ( my $val = $iter->() ) { print $val, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [stonehenge] deep copy what's the function getpwent()
by Anonymous Monk on Nov 29, 2013 at 07:53 UTC |