http://www.perlmonks.org?node_id=1016575


in reply to contextual substitution with s///?

Capture what should remain, not what should change:
$s = "test string x x\nFeb 1 09:12:33 ("; $s =~ s/^(\w{3}) /$1 /m;
Also note that if you are matching multiline string, the /m modifier is needed to match after a newline.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ