http://qs1969.pair.com?node_id=15705


in reply to how do i reset a filehandle?

I say that this can be handled many ways. My favorite is to read the whole file into a string/array/hash to then do search and replace and testing of the text.
open(INFILE, "infile.txt"); my $filesize = -s INFILE; read(INFILE, $temp, $filesize); close(INFILE); $temp = /(regex here)/; and your other stuff here

Replies are listed 'Best First'.
RE: RE: how do i reset a filehandle?
by kryten (Scribe) on Jun 01, 2000 at 14:45 UTC
    This gets really bad when you have to deal with large files. (how much memory do you have?) I would suggest getting out of this habit as soon as possible. As others have mentioned, use seek.