in reply to Looking for pointers or optimizations.

You have some strange things going on at the top of your file. Comments interspersed:

my $words_file = @ARGV; # Evaluating an array in scalar context returns the length # of the array. So if you are passing your script one filename, # $words_file will equal '1', not the first argument from the # command line. Pass it two filenames, and it will equal 2, etc. # But that doesn't matter, because of another bug: open (my $fh, ">", $words_file); # Here you open the file for writing, but never use it. # (You should also check for errors, or use autodie.) my @words; while (<>) { push(@words, $_); } # Which turns out also not to matter, because you then use # the <> operator, which reads from the files in @ARGV # automagically. So lines 4 & 5 (the first two I quoted), # though broken, don't affect anything else, and could be # discarded.

Aaron B.
Available for small or large Perl jobs; see my home node.