my @sets = map { my $x = $_; # Copy outer loop variable [map { $x ** $_ } (1..3)]; } (1..3);