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

Re: Serious problem with perl -pi -e

Thread Previous | Thread Next
From:
John W. Krahn
Date:
April 27, 2002 03:38
Subject:
Re: Serious problem with perl -pi -e
Message ID:
3CCA7FAC.F544D1D4@acm.org
Sharan wrote:
> 
> Hello,

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.

Supply a string to the -i switch and perl will save the original file
with that string appended to the file name.  For example:

perl -pi.bak -s's/somestring/somethingelse/g' textfile.txt

Will save the original file as "textfile.txt.bak" and the modified file
as "textfile.txt"


John
-- 
use Perl;
program
fulfillment

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