in reply to Array indices
which i could use like this:sub arrloop { my ($arrays, $code) = @_; # keep calling code until we've been through all of the # arrays. for (my $i = 0; grep { $i <= scalar(@$_) } @$arrays; $i++) { $code->(map { $_->[$i] } @$array); } }
this is just as contrived an examples as Limbic~Region's example, but my question is about iterating over arrays, not proper choice of data structures. if i'm not mistaken perl6's for will solve this.arrloop [\@first, \@middle, \@last], sub { my ($first, $middle, $last) = @_; print "Hello $first $middle $last\n"; }
Edit: s/PRE/CODE/ tags. larsen
|
|---|