package AnyData::Format::ReaperLogs; use strict; use warnings; use AnyData::Format::Base; use vars qw( @ISA $DEBUG $VERSION); @AnyData::Format::ReaperLogs::ISA = qw( AnyData::Format::Base ); $DEBUG = 0; $VERSION = (qw $Revision: 1.1 $)[1]; sub new { my $class = shift; my $self = shift || {}; $self->{col_names} = 'string,date,reason,action,action_value,user,cmd'; $self->{record_sep} = "\n"; $self->{key} = 'datestamp'; $self->{keep_first_line} = 0; return bless $self, $class; } sub read_fields { print "PARSE RECORD\n" if $DEBUG; my $self = shift; my $str = shift || return undef; print "RECORD = $str\n" if $DEBUG; my (@row) = $str =~ /^(\w+\s\w+\s+\d+\s\d\d:\d\d:\d\d\s\w+\s\d\d\d\d) # $1 = Tue Aug 26 09:31:46 EDT 2003 \s::\s\( # Delimiter ([^\)]*) # $2 = Reason \)\s # Delimiter (\w+) # $3 = action \s([^:]*?) # $4 = action_value :\sUSER\s # Delimiter ([^,]+) # $5 = user ,\sCMD\s' # Delimiter (.*) # $6 = cmd '$ # End of record /x; return ($str) unless (@row); print "VALUES = @row\n" if $DEBUG; return ($str,@row); } 1; |