Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Index a file with pack for fast access

by Ineffectual (Scribe)
on Dec 16, 2011 at 19:00 UTC ( [id://944000]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    open(IN, $oneper) or die "Can't open file $oneper for reading: $!\n";
    open(INDEX, "+>$file.idx") or die "Can't open $file.idx for read/write
    +: $!\n";
    ...
            $offset = tell($data_file);
        }
    }
    
  2. or download this
    # usage: line_with_index(*DATA_HANDLE, *INDEX_HANDLE, $LINE_NUMBER)
    # returns line or undef if LINE_NUMBER was out of range
    ...
        seek($data_file, $d_offset, 0);
        return scalar(<$data_file>);
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://944000]
Approved by moritz
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-25 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found