in reply to simple substitution

1. You open the file and you close it, never read nor write from it. You should try and read up on file handles and loops.

Something ala..

while(my $line = <INHANDLE>) { $line=~s/word1/word2/; print OUTHANDLE $line; }
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.

When you are done closing your original and temp files, remove the original and rename the new to the old one.


Play that funky music white boy..