in reply to Pimp My RegEx

You don't need to slurp. Either the line matches the regex /^$date_regex/ or it doesn't. (I'm assuming there's no chance the middle of a record will match that regex.)
perl -n -e '$count++ if /^REGEX/;}END{print "$count\n";' FILENAME

And, yes, 55mb will blow out a 3G+ RAM. You should expect a 10-1 to 20-1 increase in memory usage over disk size. This is Perl ...


  • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
  • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"

Replies are listed 'Best First'.
Re^2: Pimp My RegEx
by Roy Johnson (Monsignor) on May 31, 2005 at 18:50 UTC
      I was unclear - you wouldn't need the whole regex anymore. The problem has been restated, so the new regex should be more restrictive. At the very minimum, it would not be capturing across $/.

      • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
      • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"