SPUG: Open big files

Tim Maher tim at consultix-inc.com
Thu Jan 22 12:40:43 CST 2004

On Thu, Jan 22, 2004 at 09:12:09AM -0800, Luis Medrano wrote:
> List,
> I have a question I need to open a files between 5 and 35 megs
> and work with those files but my question is how can I open the
> files using the min amount of memory??..
> Thanks,
> Luis

If the processing you need to do allows it, just read the lines
one at a time, in a loop -- then you'll only have one line's worth
of memory in use at any time.

If you need to actually have access to the files as if they were
in memory (without paying the price for really storing them there),
you could use the Tie::File module: 

Have fun!

| Tim Maher, CEO     (206) 781-UNIX      (866) DOC-PERL     (866) DOC-UNIX |
| tim(AT)Consultix-Inc.Com  http://TeachMePerl.Com  http://TeachMeUnix.Com |
|  Watch for my Manning book: "Minimal Perl for Shell Users & Programmers" |

More information about the spug-list mailing list