First page Back Continue Last page Overview Graphics
sub read_fields
sub read_fields {
my ($self, $str) = @_;
return unless $str;
my (@row) = $str =~ /
# Column Delimeter
^(\w+\s\w+\s+\d+\s\d\d:\d\d:\d\d\s\w+\s\d{4}) \s::\s\(
([^\)]*) \)\s
(\w+) \s
([^:]*?) :\s(?:PID\s\d+,\s)?USER\s
([^,]+) ,\sCMD\s'
(.*) '$/x;
return @row ? ($str, @row) : $str;
}
Notes:
This defines the regular expression that we will use to parse the individual fields out of each log line.
The read_fields method will be called once for each line read in from the file.
If we wanted to support writing to the log file, we could have also written a write_fields method to handle that.