I'm not sure he really wants an unanchored regex with
/g.. it might have some surprising effects down the road. Note that since you're using
.*, so long as the variable contains a single line at a time, the
/g won't do anything since the regex machine will match the entire string from the first opening to the last closing paren. As a minor point, if you're substituting against
$_ you needn't spell out the variable with
=~; although you may have chosen to do so for clarity.
Makeshifts last the longest.