GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  ARRAY::FILEREADER (3)

.ds Aq ’

NAME

Array::FileReader - Lazily tie files to arrays for reading

CONTENTS

SYNOPSIS



  use Array::FileReader;
  tie @foo, Array::FileReader, "some.file";
  print $foo[30];



DESCRIPTION

Plenty of times I’ve wanted to run up and down a file like this:



    @foo = <FILE>;
    for (0..100) {
        print $foo[$_];
    }
    print $foo[10], $foo[20], $foo[30];



Of course, this is hugely inefficient since you have to load the entire file into an array in memory. Array::FileReader removes the inefficiency by only storing the line offsets in memory, and only discovering the line offsets when a line is called for. For instance, $foo[4] will only load 4 numbers into memory, and then $foo[30] will load another 26.

Because the file offsets are discovered when needed, there’s no good way of getting the size of the file - you just have to pad through them all, which is slow.

The module was designed to speed up Mark-Jason Dominus’ Algorithm::Diff module when finding differences between two very large files. In fact, it makes things less efficient, since the first thing that module does is find the size of the arrays. It just goes to show, doesn’t it?

MAINTAINER

Curtis Ovid Poe, <1napc-pmetsuilbup@yahoo.com>

Reverse the name to email me.

AUTHOR

Simon Cozens, <simon@cpan.org>

SEE ALSO

Algorithm::Diff, Tie::MmapArray
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 ARRAY::FILEREADER (3) 2005-10-07

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.