I have one small problem! HowTo read from large text file text in binary mode?
if i want read all file, i use this code:
my (@LOG_FILE); open (FL, "/var/log/maillog"); @LOG_FILE=<FL>; close (FL); #After this code execution file contents stored in array @LOG_FILE @LOG_FILE=grep /$something/, @LOG_FILE
I not want read all file string by struing - it's so slowly, if file is large and contains more than 1000000 records!
I need read each 500000 bytes, but how?
Please, help!
When you are opening big files never do
@array = <FILE>
This essentially reads the entire file into an array and is very expensive on memory.
you could do something like while(<FILE>){ push @arr , $_ if(/$something/); }
But IMHO this still that may not be the best way.
What I would do is
system("grep $something $filename > $tempfile"); # *Nothing* beats gnu grep when you parse large file
open(FILE,$tempfile); # Now if you really want the lines in an array @lines = <FILE>
Ram
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]