use warnings; use strict; #define constants my $datapath="F:\\wordsinwords\\"; my $wordfile= $datapath."wordlist.txt"; #define variables my $outrecs=0; my $word; open LOG, ">".$datapath."wordsinwords_LOG.txt" or die $!; select LOG; $|=1; #read the wordlist file into an array open (WORDFILE, $wordfile); chomp (@words = ()); close (WORDFILE); #main #coerce the array into a hash %hash = map { $_ => 1 } @words; #search for matches #I have no idea how to put a single #regex together that could meet all of the criteria so #I was going to run this multiple times to target specific #criteria until I found all permutations. foreach $word (keys %hash) { $outrecs++ if /.+$searchword/ ~~ %hash; } #=============================================== # This was an attempt at using an array # but it was also very slow #=============================================== #foreach $word (@words) { # $outrecs++ if ($found) = grep (/.+?$word/, @words); #} #close files & write out completion log print LOG "Created output file with: ".$outrecs." records.\n"; close LOG;