Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

RE: how do i reset a filehandle?

by BigJoe (Curate)
on Jun 01, 2000 at 00:50 UTC ( #15705=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://15705]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2023-06-08 11:58 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (30 votes). Check out past polls.