Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


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:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11126561]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-18 01:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found