in reply to Re: $^I why this symbol does not work ?
in thread $^I why this symbol does not work ?

to:Corion\
Yes.my OS is windows XP.
you mean :In windows XP, when a fle is opened,we cannot save/modify it at the sametime ?
now i want to replace some words then save it ,how i should do?
perl -p -i -e "s/<String to Find>/<String to replace>/g" <File Name>
I try this ,an error occurs :Can't do inplace edit without backup.
i don't want any bakup files .
this is a shortcut,If i want to write a program,how i finish this job ?
  • Comment on Re^2: $^I why this symbol does not work ?

Replies are listed 'Best First'.
Re^3: $^I why this symbol does not work ?
by Corion (Patriarch) on Oct 01, 2008 at 06:59 UTC

    No. Under Windows, you cannot use -i, you have to use -i.bak or something like that, because you cannot "rewrite" a file on the fly, at least not with the simple approach that the -p switch does.

    You will need to create the backup file and then erase it afterwards.

      Oh.i got it.
      i must create a BAK files .And then i can delete it,:-D.
      thanks all above.
Re^3: $^I why this symbol does not work ?
by lamp (Chaplain) on Oct 01, 2008 at 07:00 UTC
    On windows system, you can use the following one liner.
    perl -pi.bak -e "s/<String to Find>/<String to replace>/;" <File Name>
    And ofcourse, it will create a backup of original file with .bak extension.
      i got it.
      thank you!:-D