sub pancake {
        my @x = @_;
        for my $idx (0 .. $
                my $min = $idx;
                $x[$min] > $x[$_] and $min = $_           for $idx + 1 .. $

                next if $x[$min] == $x[$idx];

                @x[$min .. $
                @x[$idx .. $
        }
        @x;
}

my @a = map (int rand(100), 1 .. 10);
print "Before @a\n";
@a = pancake(@a);
print "After  @a\n";