Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
if any of you would care to assist me...
im writing a script which opens itself does a bunch of modifications and then writes the changed code to another file.
first, it opens itself, reads certain lines into an array, then writes these lines to another file, then opens that file, does some more modifications (it does them on the file instead of the array because the code needs to pass over all the data at once , so i unset $/) and then i want it to write that output back to the file, but i cant write it back to the same file because if the file is opened for updating it, the file gets messed up, and if its opened for the other kind of read-write, then it gets clobbered...i know i could create a third file as a temp file but i'd rather not..so what i really need is either a way to traverse an entire array in one step so i dont have to write it to a file before everything is done, like unsetting $/, but for an array, or a way to solve the problem otherwise without creating a third file.
thank you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: file editing/writing
by merlyn (Sage) on Jun 04, 2001 at 02:23 UTC | |
|
Re: file editing/writing
by Beatnik (Parson) on Jun 04, 2001 at 01:57 UTC | |
|
Re: file editing/writing
by Anonymous Monk on Jun 05, 2001 at 19:05 UTC |