in reply to Can perl do...?

($foo = "one two three") =~ s/two/2/; This does what you want I think - although why you woud do this, unless the s// was generated on the fly