Q:

perl regex period matches zero length character

For example:
$ perl -pe 's/(.)\G/{$1}/g'
abcd

and the result is:
{}{a}{b}{c}{d}

the first period(.) match is zero length. Is this a bug or a feature?

A:

For me the result is "abcd", because /(.)\G/g can never match — how can it match a single character before the current position, starting at the current position? s/\G(.)/{$1}/g on "abcd" produces "{a}{b}{c}{d}", which is expected.

