$string="asdfadfadfadsfasdf YOU!"; $string=~s/(.*C)(.*)/HEY/; # Substitute the whole string with HEY print $1, "\n"; print $2, "\n"; print "$string\n";