Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Reading from a file

by TedPride (Priest)
on May 23, 2006 at 08:57 UTC ( [id://551102]=note: print w/replies, xml ) Need Help??


in reply to Reading from a file

Does the file change between loads? If not, you can just run through the file once and generate a list of line positions (use pack to compress each position into 4 bytes, rather than storing the positions as longer, not fixed-length strings), then from then on jump to the index position corresponding to the line you want, grab 4 bytes, unpack to find the line position, then go to that position in the main file and read the record.

Or you can use Tie::File, but where's the fun in that? :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-24 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found