in reply to How to make references more like aliases?
is not going to preserve aliasing. @group is going to get copies of whatever was used in the return statement of the iterator.while ( my @group = $next->() )
Instead, you'll have to return an array reference. As for getting the aliases, the only way to get aliases is through argument passing. An idiomatic way is with:
In terms of your code, you change the return line of the iterator to:my $arrayref_of_aliases = sub { \@_ }->( $stuff, $to, $alias );
Then it works as you'd expect (with the appropriate changes in the calling code's while loop).return sub { \@_ }->( @$list[ $start .. $stop ] );
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to make references more like aliases?
by Limbic~Region (Chancellor) on Sep 28, 2004 at 00:52 UTC |