http://www.perlmonks.org?node_id=1193779


in reply to Minimally changing combinations

What do you need a module for?

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1193761 use strict; use warnings; my @list1 = qw( a b c ); my @list2 = qw( 1 2 ); my $reverse = 0; my @combinations = map { my $left = $_; map "$left $_", $reverse++ % 2 ? reverse @list2 : @list2 } @list1; print for @combinations;