in reply to simple substitution
Something ala..
2. If you are processing one file and wishing to change it, i might advise opening one file to read from as your original, and a tempfile as your output. modifying the file you are reading from works /sometimes/. Anyway, read your file in, and write out your changes to a temp file created via File::Temp.while(my $line = <INHANDLE>) { $line=~s/word1/word2/; print OUTHANDLE $line; }
When you are done closing your original and temp files, remove the original and rename the new to the old one.
|
|---|