use warnings; use strict; open LOG, ">", 'wordsinwords_LOG.txt' or die $!; #Sort alphabetically first so identical words end up together. chomp (my @words = sort { length($a) <=> length($b) } sort ); @words = map {lc} @words; for (my $i=0; $i<$#words; $i++) { my $word = $words[$i]; next if $word eq $words[$i+1]; my @matched = grep {/$word/ and $_ ne "${word}s" and $_ ne "${word}'s" } @words[$i+1..$#words]; print LOG "$word => @matched\n" if @matched; } __DATA__ at Ate crate tree Trip tread read ad at ads crate's