in reply to best way to implement multiple foreach iterator variables?
my $cur_index = 0; while ( $cur_index <= $#x - 1 ) { my ($x, $y) = @x[$cur_index .. $cur_index + 1]; $cur_index += 2; # Do stuff with $x and $y }
If you want the aliasing capabilities, look into Data::Alias.
As for the neat P6 syntax (for @x -> $x, $y { ... }), you'll be needing a source filter for that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: best way to implement multiple foreach iterator variables?
by adrianh (Chancellor) on Feb 19, 2006 at 14:34 UTC |