Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sun-barr!newstop!texsun!convex!convex.com!rhall From: rhall@convex.com (Randy Hall) Newsgroups: comp.lang.perl Subject: perl -i bug Message-ID: <111455@convex.convex.com> Date: 15 Dec 90 23:06:42 GMT Sender: news@convex.com Reply-To: rhall@convex.com (Randy Hall) Organization: Convex Computer Corp, Richardson, TX Lines: 20 I ran into this problem using perl (patch level 40). Using perl -i to edit a file in place fails when the directory is not writable. The file is zeroed, and no warning is given. Create FILE which has write permission. Put it in a directory which does not have write permission. Try: perl -p -i.bak -e "s/foo/bar/" FILE I think this is what happens: perl will try to rename FILE to FILE.bak, but cannot because write permission is denied. Then perl tries to read from FILE.bak putting the output in FILE. This results in zeroing FILE. I think perl should quit after not being able to make the backup and print an error message. If no backup is requested, perhaps perl could use /tmp when the current directory isn't writable. Thanks, Randy Hall rhall@convex.com Convex Computer Corporation Richardson, TX