Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 16th, 2012  |  syntax: Perl  |  size: 0.45 KB  |  views: 313  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use List::Util qw(shuffle);
  5. use Data::Dumper;
  6. $Data::Dumper::Indent = 0;
  7.  
  8. unless (defined $ARGV[0]) {
  9.         $ARGV[0] = 5;
  10. }
  11. for (1 .. factorial($ARGV[0])) {
  12.         my @array = (0 .. ($ARGV[0] - 1));
  13.         @array = shuffle(@array);
  14.         print Dumper( \@array ) . "\n";
  15. }
  16.  
  17. sub factorial {
  18.         my $n = shift;
  19.         my $f = 1;
  20.         $f *= $n-- while $n > 0;
  21.         return $f;
  22. }
clone this paste RAW Paste Data