Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

RE: how do i reset a filehandle?

by BigJoe (Curate)
on Jun 01, 2000 at 00:50 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found