Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -w
    # DESCRIPTION: Generate permutations in lexicographic order
    ...
       my ($i,$j) = @_; my $t = $a[$i];
       ($a[$i],$a[$j]) = ($a[$j],$t);
    }
    
  2. or download this
    #!/usr/bin/perl -w
    use strict;
    die "bleah... nothing to permutate\n" unless defined @ARGV; 
    use Algorithm::Permute qw(permute permute_ref);
    print join(" ", @$_), "\n" for permute(\@ARGV);