Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The (-i) switch is so easy for adjusting TEXT files. I use this so often, that in my login script, I set an alias for pie=perl -p -i~ -e. Easy as pie.
However, -i really doesn't edit "in place," but it does a good simulation of it. It creates a new file and moves the old file to a backup extension. You may have problems with access control lists (ACLs) on some network file system implementations. Experiment. The '+' modes for the open() function are designed for fixed-record DATA updating. Note both examples in (perldoc -f open) refer to database files. Not that you couldn't use the functions for text files, but it would be a horrible and unnecessary tangle of seek(), tell() and caching to avoid overwriting parts of the next line before it is read. Not to mention further complications for newline conversion entanglement. I wish the docs were more clear about this, to avoid this recurring question. -- In reply to Re: In-place file manipulation
by halley
|
|