zip#
Walk multiple arrays in lockstep, returning one arrayref per row.
Registered under both zip and zip_longest. Both forms stop at
the length of the longest input and fill missing positions with
undef.
Synopsis#
my @rows = zip \@a, \@b, \@c;
my @rows = zip_longest \@a, \@b, \@c;
foreach ( zip \@xs, \@ys ) {
my ($x, $y) = @$_;
}
What you get back#
A list of arrayrefs, one per row. Row i contains the i-th
element of each input array in order. Shorter inputs contribute
undef beyond their own length.
Examples#
my @r = zip [1..3], ['a'..'c']; # ([1,'a'], [2,'b'], [3,'c'])
my @r = zip [1..3], ['a'..'b']; # ([1,'a'], [2,'b'], [3,undef])
Differences from upstream#
Fully compatible with upstream.
See also#
zip_shortest— stop at the shortest input.mesh— flatten the rows instead of wrapping in arrayrefs.