I'm trying to use the Tie::File module to access large text files. The
test file I'm working on now is about 42MB.
According to the instructions at
http://aspn.activestate.com/ASPN/docs/ActivePerl/5.8/lib/Tie/File.html,
"Tie::File represents a regular text file as a Perl array. Each element
in the array corresponds to a record in the file. The first line of the
file is element 0 of the array; the second line is element 1, and so on."
and...
"The file is not loaded into memory, so this will work even for gigantic
files."
Sounds perfect. That's just what I need.
However, there appears to be a caveat in that this module can run very
slowly while it is binding itself to a file.
I don't understand that. If the file is not being loaded into memory,
what's the holdup?
Anyway, all I'm trying to do right now is get a reading on how many
lines (records) there are in my test file, but the script simply grinds
and grinds.
My somewhat abbreviated code:
use Tie::File;
use Fcntl 'O_RDONLY';
tie ( @lines, "Tie::File", "$testfile", mode => O_RDONLY ) or die
"\nUnable to Tie File >$testfile< \n" ;
my $n_recs = @lines;
print "\n\tThere are $n_recs records or lines are in the file\n";
-- Craig
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0610-1, 03/08/2006
Tested on: 3/10/2006 11:39:49 AM
avast! - copyright (c) 1988-2004 ALWIL Software.
http://www.avast.com
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs