($sEnd) = map {uc} map {s/world/todo el mundo/; $_} map {local $_ = $_; s/hello/goodbye/; $_} $sBegin; # Or: ($sEnd) = map {uc} map {s/world/todo el mundo/; $_} map {s/hello/goodbye/; $_} map {local $_ = $_} $sBegin;