http://www.perlmonks.org?node_id=1035916


in reply to Matching with /g: Is this a bug?

Noone seems to have mentioned the bug is your inappropriate use of g in scalar/void context. Remove the g from the first match, and it'll work fine.