Good morning monks,
Hope the regex experts out there can help out on this one: I have a large file of international news stories and want to count how many stories there are from each country (doesn't have to be exact). The file is formatted like so:
Headline of story is here Text of story is here Text of story is here Text of story is here Headline of story is here Text of story is here Text of story is here Text of story is here
Eyeballing the file shows that most headlines do in fact have the country name in them, so it seems like OWTDI would be just to count the occurrences of country names in the headlines only, ignoring the text. How can I modify the regex in the following loop to do that?
while (<NEWS>) { foreach my $country (@countries) { $story_count{$country}++ if m/$country/gi; } }
Thanks in advance, mooseboy
In reply to Counting words in headlines by mooseboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |