in reply to Combine Two Scripts Into One

To clean up the code of your first script a little bit, we get this:
#!/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;
And if we want to include a modified version of toolic's uniqueness check, we end up with this:
my %seen; while (my @set = $perm->next) { my $str = join '', @set; print $fh "$str\n" if ! $seen{$str}++; }