in reply to To add a string to the content of a file
If you run that on its own then I would expect you will get no output at all because you don't print anything anywhere inside the loop. Perhaps what you want is:
while (<>){ if (/^#!/){ $_ .= "Add this line.\n"; } print; }
|
|---|