in reply to Re: Using regex in Map function
in thread Using regex in Map function
or, even better, thisThat may be subject to judgement.
While your 1st and 3rd variant append behind the line-ending newline, the 2nd is probably closer to what the OP wanted, since $ is matching before that newline.
In Section
Seekers of Perl Wisdom