SHARE
TWEET

Untitled

a guest Feb 16th, 2012 318 Never
  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. }
RAW Paste Data
Top