The stupid question is the question not asked | |
PerlMonks |
Re: Word Count and Match (updated)by AnomalousMonk (Archbishop) |
on Jan 07, 2021 at 21:26 UTC ( [id://11126561]=note: print w/replies, xml ) | Need Help?? |
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: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|