in reply to Re^2: undefined or zero: loking for an elegant solution
in thread undefined or zero: looking for an elegant solution

yes *facepalm* of course ;-)

The construct with parens is necessary for substitution after assignment, not just for plain conditional assignment.

($foo = $bar) =~ s/$pat/$subst/; # operates on $foo