Ah, ok, so thats a "feature" of perls regex engine. So basically that code is doing to same thing as me just duplicating the $gw var and then matching against those newly created variables.
Maybe its my missunderstanding of "g" but I was thinking that meant globally match anywhere in the string. So if I was wanting to match "def" in the string of "abcdefg" then I would use the "g" otherwise I'd have to match on something like /.*def.*/ Is that incorrect?