zip_shortest#

Walk multiple arrays in lockstep, stopping at the shortest.

Synopsis#

my @rows = zip_shortest \@a, \@b, \@c;

What you get back#

A list of arrayrefs, one per row. Row i contains the i-th element of each input array — produced only while every input still has an i-th element. No undef padding.

Examples#

my @r = zip_shortest [1..3], ['a','b'];   # ([1,'a'], [2,'b'])
my @r = zip_shortest [1..3], [];          # ()

Differences from upstream#

Fully compatible with upstream.

See also#

  • zip / zip_longest — pad to longest instead.

  • mesh_shortest — flatten the rows instead of wrapping in arrayrefs.