Perl implementation of shuf