unpairs#
Flatten a list of two-element arrayrefs into a key/value list.
Synopsis#
my @kvlist = unpairs @pairs;
my %hash = unpairs @pairs;
What you get back#
A flat list with exactly two elements per input arrayref: [0]
becomes the key, [1] becomes the value. Missing elements and
non-arrayref inputs pad with undef so that the result is always
even-sized.
Examples#
my @kv = unpairs [a => 1], [b => 2]; # ('a', 1, 'b', 2)
my %h = unpairs pairs %other; # round-trip
my @kv = unpairs sort { $a->[0] cmp $b->[0] } pairs %h;
Differences from upstream#
Fully compatible with upstream.
See also#
pairs— the inverse direction.