Last Updated: February 25, 2016
·
546
· alexdenisov

Iterate few lists with Perl

use List::MoreUtils qw( each_array );

my @first = qw( foo bar buzz );
my @second = (1, 2, 3);

my $it = each_array( @first, @second );
while ( my ($f, $s) = $it->() ) {
  print "$f = $s\n";
}

# Output
# foo = 1
# bar = 2
# buzz = 3  

https://gist.github.com/4603229