in reply to Re^3: Newbie Q:How do I compare items within a string?
in thread Newbie Q:How do I compare items within a string?

I don't think that's the difference. I split on separator characters when forming the array @words but I negate the character class when doing the s{ ... }{ ...}xeg to add the annotation. Thus, like you, I am pulling out words but by capturing one or more non-separator characters.

Cheers,

JohnGG

Update: I substituted your pattern

([A-Za-z']+)(?{++ $found{lc $1}})

for my pattern

([^.,;:?! \n]+)(?{++ $found{lc $1}})

and the results were identical.