#!/usr/bin/perl use strict; use warnings; use List::Permutor; my $outfile = 'permutations.txt'; open my $fh, '>', $outfile or die "$outfile: $!"; my $word = 'aabc'; my $perm = new List::Permutor split(//,$word); while (my @set = $perm->next) { my $str = join '', @set; print $fh "$str\n"; } close $fh; #### my %seen; while (my @set = $perm->next) { my $str = join '', @set; print $fh "$str\n" if ! $seen{$str}++; }