in reply to Re: How do I just count any words from a file?
in thread How do I just count any words from a file?

The regular expression isn't an array you can foreach through
It returns a list of matches. So actually, he can.
It returns something like a true false value while the iterator is true instead.
Not with /g in list context. Even when there are no capturing parens, because then you'll still get a list of matches for the entire pattern.
So choose while instead of foreach here. See if something like this works better
It'll use less memory, but otherwise, both should have pretty much the same end result.
  • Comment on Re^2: How do I just count any words from a file?