in reply to Re: How do I assign & substitute in one statement?
in thread How do I assign & substitute in one statement?

Important thing I overlooked: your solution modifies $sBegin!

You would need to create a copy before modifying. One way:

($sEnd) = map {s/hello/goodbye/g; $_;} map {$_} ($sBegin);
Another:
($sEnd) = map {s/hello/goodbye/g; $_;} @{[$sBegin]};
A functionally similar solution that doesn't use map:
$sEnd = do {local $_ = $sBegin; s/hello/goodbye/g; $_;};
Of course, creating a copy and working on it is the canonical solution:
(my $sEnd = $sBegin) =~ s/hello/goodbye/g;
This couldn't be used in a combination declaration-assignment, though, while the others could.

Caution: Contents may have been coded under pressure.