in reply to Combine Two Scripts Into One

Instead of slurping the entire permutations.txt file (which is probably big) into your 2nd script, just loop over the lines of the file:
my %seen; while (<ALLPERMUTATIONS>) { chomp; $seen{$_} = 1; } print "$_\n" for keys %seen;