in reply to Help to improve script that searches a file for key words in a second file.
Something like this:
I don't have PERL on this machine so any minor syntax issues are your problem :o)# read terms file open (SRC, $searchTermsFile) || die "can't open search terms file"; @terms = <SRC>; chomp (@terms); # read annotations file... open(my $f, '<', $file) or die "OPENING $file: $!\n"; my $string = do { local($/); <$f> }; close($f); my %nTermHits; foreach my $term (@terms) { $nTermHits{$term} = () = $string =~ /\b$term\b/ig; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help to improve script that searches a file for key words in a second file.
by mastarr (Novice) on Apr 01, 2013 at 19:29 UTC |