This is an oddball issue I\'ve encountered (and probably have seen before but never paid attention to).
Here\'s the gist of the code:
my $url = \'htt
The gist of it is that matches done with /g save the position of the last match, so that the next time that string is matched, the regex will start from there. In scalar context, this is generally done to get multiple successive matches in a while loop; In list context, /g returns all the matched (but not overlapping) results. You can read more about this on perlretut, under Global Matching, and on perlop, under Regexp-Quote-Like-Operators.
You can see the current position with the pos function. You can also set the position by using pos as an lvalue: pos($string) = 0;
will reset the position to the beginning of the string.
There isn't much reason to use /g in scalar context outside of a loop, as you can get the exact same functionality using the \G assertion.
..of course, then nobody remembers how \G works and you are back at square one, but that's another topic.