# Open puzzle file and print ## open(IN, "/Users/TMP/Puz.txt") or die "Can't open Puz.txt for reading: $!\n"; @words = ; foreach $word(@words) { chomp($word); # print "$word\n"; push(@words2, $word); } close(IN); # open refernce file for words to find open REF, "/Users/TMP/Ref_file.txt" or die "Can't open Ref_file.txt for reading: $!\n"; my @refs = ; foreach $ref(@refs) { chomp($ref); push(@refs2, $ref); } ############################## # Process array &find_words(@words2); # find words subroutine sub find_words { while(@words2) { $words = shift(@words2); foreach $ref(@refs2) { if($words =~ /$ref/gi) { print "$`","~\U$&~","$'","\n"; } } } } #### sub find_words { print "Here are the answers!\n\n"; while (@input2) { $in = shift(@input2); $in =~ s{($regexp)}{ **\U$1\E** }g; print "$in\n"; } exit; }