OT: perl vs shell cmd

Beast beast at i6x.org
Tue Jun 14 06:14:16 UTC 2005


Supose I want to parse a big log file (~500MB/4mil lines), which one is 
faster and use less memory:


$ ./parser.pl logfile.log

or

$ grep 'Jun 14 03:' | ./parser.pl

Log file is 24 hours and it will be processed every hour.

------
parser.pl:
$in_time = 'Jun 14 03:';

while(<>)
{
    if(/^$in_time/ {
       # do some processing
    }else {
       next;
    }
}


-- 

--beast




More information about the fedora-list mailing list