in reply to Word Count and Match
my $wordcnt='Bob|Tom|Dave|Tom|Bob|Dave';
What is the significance of the repetition of words in $wordcnt? Repeated patterns in a regex alternation have no effect. The regexes /Bob|Tom|Dave/ and /Bob|Tom|Dave|Tom|Bob|Dave/ and /Bob|Tom|Dave|Tom|Bob|Dave|Dave|Tom|Bob|Dave|Bob/ are equivalent.
... the code also gives a total word count ...
I don't see how the posted code does this.
... MATCH the wordcnt with the FIELD in the flat file.
This implies that each word being searched for occurs only once in a line from the flatfile (or maybe in the the entire flatfile). Is this true?
Update: There are no boundary assertions in the OPed pattern, so 'TomTom' will count 'Tom' twice. Is this what you want?
Give a man a fish: <%-{-{-{-<
|
|---|