NAME Syntax::Operator::Zip - infix operator to compose two lists together SYNOPSIS On a suitably-patched perl: use Syntax::Operator::Zip; foreach (@xvals Z @yvals) { my ($x, $y) = @$_; say "Value $x is associated with value $y"; } Or, on a standard perl: use v5.14; use Syntax::Operator::Zip qw( zip ); foreach (zip \@xvals, \@yvals) { my ($x, $y) = @$_; say "Value $x is associated with value $y"; } DESCRIPTION This module provides infix operators that compose two lists of elements by associating successive elements from the left and right-hand lists together, forming a new list. OPERATORS Z my @result = @lhs Z @rhs; # returns [$lhs[0], $rhs[0]], [$lhs[1], $rhs[1]], ... Yields a list of array references, each containing a pair of items from the two operand lists. If one of the operand lists is shorter than the other, the missing elements will be filled in with undef so that every array reference in the result contains exactly two items. M my @result = @lhs M @rhs; # returns $lhs[0], $rhs[0], $lhs[1], $rhs[1], ... Yields a list of the values from its operand lists, rearranged into pairs and flattened. If one of the operand lists is shorter than the other, the missing elements will be filled in with undef so that the result is correctly lined up. The result of this operator is useful for constructing hashes from two lists containing keys and values my %hash = @keys M @values; FUNCTIONS As a convenience, the following functions may be imported which implement the same behaviour as the infix operators, though are accessed via regular function call syntax. The two lists for these functions to operate on must be passed as references to arrays (either named variables, or anonymously constructed by [...]). zip my @result = zip( \@lhs, \@rhs ); A function version of the "Z" operator. See also "zip" in List::Util. mesh my @result = mesh( \@lhs, \@rhs ); A function version of the "M" operator. See also "mesh" in List::Util. AUTHOR Paul Evans