in reply to tcl like 1 loop with two operators

I'd use List::MoreUtils::natatime ("n at a time"):

my $it = natatime 3, 1,2,3,4; while (my $i, $j = $it->()) { ... };

... or, if you have the data in two lists already, List::MoreUtils::pairwise (or ::each_arrayref, but have a look List::MoreUtils yourself)

pairwise { print $a; print $b; } @a, @b

Replies are listed 'Best First'.
Re^2: tcl like 1 loop with two operators
by AnomalousMonk (Archbishop) on Jan 24, 2011 at 17:30 UTC

    E.g., with List::MoreUtils::each_array():

    >perl -wMstrict -le "use List::MoreUtils qw(each_array); my @ra = qw(a b c); my $pair_iter = each_array @ra, @{[ qw(x y z) ]}; while (my ($i, $j) = $pair_iter->()) { print qq{$i, $j}; } " a, x b, y c, z