#! perl -slw use strict; use Data::Dump qw[ pp ]; use Time::HiRes qw[ time ]; #$Data::Dump::WIDTH = 1000; use Algorithm::Combinatorics qw[ permutations ]; my @a = map[ 10 *$_ .. 10 *$_ + 9 ], 0 .. 9; ## rows my $start = time; my $perms = permutations( [ 0 .. 9 ] ); while( my $p = $perms->next ) { my @perm = @a[ @$p ]; } printf "All row permutations took %f seconds\n", time - $start; ## cols $start = time; $perms = permutations( [ 0 .. 9 ] ); while( my $p = $perms->next ) { my @perm = map[ @{$_}[ @$p ] ], @a; } printf "All column permutations took %f seconds\n", time - $start; __END__ C:\test>PermsMatrix.pl All row permutations took 17.198000 seconds All column permutations took 65.284842 seconds