[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-AnyPerl] Updating Files



I have a script that generates a data file that I wish to update.  The files
structure is simply:

1st Line: Date & Time Stamp.
2nd Line: Data Column Labels.
nth Line: Columnar Data.

I need to:

1) Update the first two lines of the file.
2) Append data to the file.

Depending on the structure of the new data that I wish to add to the
existing data, it may be necessary for me to change (add to the end of the
line) the label line to accommodate additional data columns.

The '>>' option for the OPEN command is clearly not what I need, since I
need to read & rewrite the first two lines of the existing data file.

I tried '+>>' with OPEN, and used 'seek' and substitute operations, but this
simply appended the lines, instead of replacing the first two.

How does one do this?  Is a temp file the only way, whereby:
1) Create temp file and write existing files data to it, and close both.
   Or simply duplicate the existing file to create the temp file (I don't
   know if there is a file command in MacPerl to do this, or not).
2) OPEN '>' the existing file, write the two new date/time & label lines.
3) Open and copy the temp files data, less the first two lines.
4) Append new data.

The problem I see here, if this is indeed the way to do it, is that the
Creation date of my existing data file will change.  I do not want this to
happen.

Any suggestions would be helpful.

Thanks all in advance,
Mark
----------------------
Mark J. Yannuzzi
myannuzzi@aya.yale.edu

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org