in reply to modifying a string in place

while (<>) { s/([^^#])/$1$1/g if ($. > 4); print; }
or just perl -pe 's/([^^#])/$1$1/g if ($. > 4)' file > newfile

Caution: Contents may have been coded under pressure.