[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

OT: perl vs shell cmd




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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]