SANS Digital Forensics and Incident Response Blog: Daily Archives: May 26, 2009

Perl-Fu: Regexp log file processing

Remember that with Perl the key benefit is the ability to easily implement almost any kind of input/output processing system one might need or conceive, without the need for a lot of code or time in development. When you are faced with massive amounts of data and a small amount of analytical time, this agility is critical. I will not be teaching regular expression syntax but there are countless primers and resources on the web for this, and they almost universally apply to languages/interpreters other than Perl, including our favorite command line tool, grep. Consider the following code:

# Creates user-specific files from a single log file based on the field "User="
$logfile = $ARGV[0];
open(LOG, "