in reply to modifying a string in place
while (<>) { s/([^^#])/$1$1/g if ($. > 4); print; } [download]