develooper Front page | perl.beginners | Postings from April 2002

Re: Serious problem with perl -pi -e

Thread Previous | Thread Next
From:
Peter Scott
Date:
April 29, 2002 09:45
Subject:
Re: Serious problem with perl -pi -e
Message ID:
4.3.2.7.2.20020429094246.00ba2260@shell2.webquarry.com
At 12:35 PM 4/27/02 +0530, sharan wrote:
>Hello,
>
>I lost my files, while using perl -pi -e.
>I wanted to replace a world in a set of files, "perl -pi -e
>'s/somestring/somethingelse/g' *.pl"
>but, it gave error saying permission denied and all the files got deleted.
>
>If it cant rewrite the files, at least it should not delete.

Can you show me how to reproduce this behavior?  Here's what happened when 
I tried, first with no write permission, then with no read permission either:

$ cat foo
cat: foo: No such file or directory
$ echo "foo" > foo
$ chmod 400 foo
$ cat foo
foo
$ perl -pi -e 's/o/e/' foo
$ cat foo
feo
$ chmod 000 foo
$ cat foo
cat: foo: Permission denied
$ perl -pi -e 's/o/e/' foo
Can't open foo: Permission denied.
$ cat foo
cat: foo: Permission denied
$ chmod 400 foo
$ cat foo
feo

As you can see, the file was not deleted.  This was on Linux, what OS were 
you on?

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About