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

[MacPerl] "rewinding" a file



I think I need to rewind a file back to the beginning, but I'm not sure
how.  Close and Open seem excessive.

Maybe there's a better way to do what I'm trying to do, which is:
I want to choose records from a file according to some criteria.
Accumulate the chosen records; the number might be large (1000?).
Sort the chosen records by a $keyfield
Report the sorted results.

Sounds like a Practical Extraction and Report problem.

So what I'm doing is finding records in the main file and writing them out
to a temp file with $keyfield in front (I compute the $keyfield based on
some other stuff).
Simultaneously (approximately) I push the $keyfield onto a @list.
Then I sort the @list.
Then I open the temp file and scan through it looking for matches to the
first record in the @list.
Then I repeat for the next entry in @list.
etc.

So I'm scanning the temp file from start to finish foreach @list.

How do I get back to the start of the file for each new pass, or am I doing
this completely wrong??

J.

-->John Springer    <http://www.scruznet.com/~springer>
        Still the Penultimate Mac bigot.