use List::Util qw(all);

sub perfect_shuffle {
   my $mid = @_ / 2;
   map { @_[$_, $_ + $mid] } 0..($mid - 1);
}

for my $size (8, 24, 52, 100, 1020, 1024, 10000) {

    my @shuffled = my @deck = 1 .. $size;
    my $n = 0;
    do { $n++; @shuffled = perfect_shuffle(@shuffled) }
        until all { $shuffled[$_] == $deck[$_] } 0..$

    printf "%5d cards:%4d\n", $size, $n;
}