in reply to Is this a regex strangeness?
Indeed it matches a sequence of one or more charachters in the range [a-g] next to the newline. Precisely "g\n". In case of doubt although there's a case against $& ;-) you may try printing that to see what matched. Or else put a pair of capturing parens and print $1 which amounts to fundamentally the same thing. Or even use the return value of the match:
$ perl -pe '($_)=/[a-g]+\n/g' abcdef g g
|
|---|