inplace edit error message

N

news.verizon.net

I'm working through the examples in Jeffrey E. F. Friedl's book 'Mastering
Regular Expressions, 2nd Ed.'. I'm trying to work the example at the top of
p. 53, but I'm attempting it in a command prompt window (I'm using Windows
2000 pro). I enter:
perl -p -i -e 's/sysread/read/g' substitute.txt

I get this error message:
"Can't do inplace edit without backup."

Any ideas?

Thanks,
Al
 
J

Jim Gibson

news.verizon.net said:
I'm working through the examples in Jeffrey E. F. Friedl's book 'Mastering
Regular Expressions, 2nd Ed.'. I'm trying to work the example at the top of
p. 53, but I'm attempting it in a command prompt window (I'm using Windows
2000 pro). I enter:
perl -p -i -e 's/sysread/read/g' substitute.txt

I get this error message:
"Can't do inplace edit without backup."

Any ideas?

Thanks,
Al

Your perl is not letting you overwrite the substitute.txt file. While I
am not sure why this is so, you should be able to get around this by
specifying an extension after the -i switch. Perl will then save the
original file with this extension and write the modified file to the
original file name (untested):

perl -p -i '.bak' -e 's/sysread/read/g' substitute.txt

FYI: the comp.lang.perl news group is obsolete. Try using
comp.lang.perl.misc in the future.
 
A

Al C.

Jim,

TFYR. It ran without error this time and produced the backup file.
However, when I opened the substitute.txt file, it was unchanged. I
expected to see all occurrences of 'sysread' to be changed to 'read'. I'll
work on it some more. Thanks.
(And I'll be using the other newsgroup you mentioned).

Al
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm working through the examples in Jeffrey E. F. Friedl's book
'Mastering Regular Expressions, 2nd Ed.'. I'm trying to work the
example at the top of p. 53, but I'm attempting it in a command prompt
window (I'm using Windows 2000 pro). I enter:
perl -p -i -e 's/sysread/read/g' substitute.txt

I get this error message:
"Can't do inplace edit without backup."

I have seen this under Windows, since the Windows OS filesystem does not
have Unix's flexibility when it comes to editing a file in-place.

You'll have to specify a backup file extension with the -i option.

For your future reference, comp.lang.perl is a defunct newsgroup. General
Perl questions should be posted to comp.lang.perl.misc; you'll get a better
response there.

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP3q77mPeouIeTNHoEQIpvQCg9sk+wQ994dpbqRFJBtSh1ROLtOYAn2ZY
65N1CH3bU8n8T6XDVfd5LckO
=coZf
-----END PGP SIGNATURE-----
 
J

Jim Gibson

news.verizon.net said:
I'm working through the examples in Jeffrey E. F. Friedl's book 'Mastering
Regular Expressions, 2nd Ed.'. I'm trying to work the example at the top of
p. 53, but I'm attempting it in a command prompt window (I'm using Windows
2000 pro). I enter:
perl -p -i -e 's/sysread/read/g' substitute.txt

I get this error message:
"Can't do inplace edit without backup."

Any ideas?

Thanks,
Al

You need to specify a file extension after the -i option so that perl
has someplace to put the original file:

perl -p -i '.bak' -e 's/sysread/read/g' substitute.txt

This newsgroup is defunct. Try comp.lang.perl.misc in the future.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top