># this is a script to clean > >open(IN,"fileToClean.asc") || die "can't open!"; > >while(<IN>) { > s/Good/Bad/; > print; >} > >On the screen I can see that this is working, but when I open the file, >guess what? Nothing has changed! <snip> ...can anybody figure out what I am doing >wrong?
I'm still very new to PERL, so please don't flame me if this answer is wrong, but from the looks of this, you've got 2 problems. 1) You never print this to the file. You read in the information from "fileToClean.asc", match the information, then print it to the screen (not the file). Why would you expect the file to change? 2) Assuming your print statement was print (IN);, you'd still have a problem because you opened <IN> for reading, not writing. Again, I'm new to all this, but I thought the question has been asked "Can I open a file for read and write?", and the answer was "No". In that case, you'd have to open a second file to redirect your output to, and if you then needed it to be the same name, you could delete the original file and rename the new file. open(IN,"fileToClean.asc") || die "can't open!"; open(OUT, ">cleanfile.asc") || die "can't open OUT"; while(<IN>) { s/Good/Bad/; print(OUT) || die "Can't write to file"; } HTH Jason CONFIDENTIALITY NOTICE: ************************************************************************ The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited. ************************************************************************