diff --git a/MANIFEST b/MANIFEST index e06a592..6a1b45a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -11,6 +11,5 @@ t/parse_line.t t/pod.t t/pod-coverage.t t/samples/sample01.log -META.yml Module meta-data (added by MakeMaker) t/perl-critic.t LICENSE diff --git a/lib/Parse/IRCLog.pm b/lib/Parse/IRCLog.pm index 4a94023..b025ceb 100644 --- a/lib/Parse/IRCLog.pm +++ b/lib/Parse/IRCLog.pm @@ -24,16 +24,16 @@ our $VERSION = '1.101'; =head1 SYNOPSIS - use Parse::IRCLog; + use Parse::IRCLog; - $result = Parse::IRCLog->parse("perl-2004-02-01.log"); + $result = Parse::IRCLog->parse("perl-2004-02-01.log"); - my %to_print = ( msg => 1, action => 1 ); + my %to_print = ( msg => 1, action => 1 ); - for ($result->events) { - next unless $to_print{ $_->{type} }; - print "$_->{nick}: $_->{text}\n"; - } + for ($result->events) { + next unless $to_print{ $_->{type} }; + print "$_->{nick}: $_->{text}\n"; + } =head1 DESCRIPTION @@ -131,42 +131,42 @@ sub patterns { $p->{chan} = qr/((?:&|#)[\w\[\]\{\}\(\)&#^]*)/; $p->{nick_container} = qr/ - < - \s* - ([%@])? - \s* - $p->{nick} - (?: - : - $p->{chan} - )? - \s* - > + < + \s* + ([%@])? + \s* + $p->{nick} + (?: + : + $p->{chan} + )? + \s* + > /x; $p->{timestamp} = qr/\[?(\d\d:\d\d(?::\d\d)?)?\]?/; $p->{action_leader} = qr/\*/; - $p->{msg} = qr/ - $p->{timestamp} - \s* - $p->{nick_container} - \s+ - (.+) - /x; - - $p->{action} = qr/ - $p->{timestamp} - \s* - $p->{action_leader} - \s+ - ([%@])? - \s* - $p->{nick} - \s - (.+) - /x; + $p->{msg} = qr/ + $p->{timestamp} + \s* + $p->{nick_container} + \s+ + (.+) + /x; + + $p->{action} = qr/ + $p->{timestamp} + \s* + $p->{action_leader} + \s+ + ([%@])? + \s* + $p->{nick} + \s + (.+) + /x; $p; } @@ -185,11 +185,11 @@ sub parse { $self = $self->new unless ref $self; my $symbol = Symbol::gensym; - open $symbol, "<", $_[0] or die "couldn't open $_[0]: $!"; + open $symbol, "<", $_[0] or Carp::croak "couldn't open $_[0]: $!"; - my @events; - push @events, $self->parse_line($_) while (<$symbol>); - Parse::IRCLog::Result->new(@events); + my @events; + push @events, $self->parse_line($_) while (<$symbol>); + Parse::IRCLog::Result->new(@events); } =item C<< parse_line($line) >> @@ -204,14 +204,14 @@ If no match can be found, an "unknown" event is returned. =cut sub parse_line { - my ($self, $line) = @_; - if ($line) { - return { type => 'msg', timestamp => $1, nick_prefix => $2, nick => $3, text => $5 } - if $line =~ $self->patterns->{msg}; - return { type => 'action', timestamp => $1, nick_prefix => $2, nick => $3, text => $4 } - if $line =~ $self->patterns->{action}; - } - return { type => 'unknown', text => $line }; + my ($self, $line) = @_; + if ($line) { + return { type => 'msg', timestamp => $1, nick_prefix => $2, nick => $3, text => $5 } + if $line =~ $self->patterns->{msg}; + return { type => 'action', timestamp => $1, nick_prefix => $2, nick => $3, text => $4 } + if $line =~ $self->patterns->{action}; + } + return { type => 'unknown', text => $line }; } =back @@ -227,7 +227,7 @@ only one or two patterns. For example, to use the default C pattern but override the C or C. This sounds like a very good idea, actually, now that I write it down. -=head1 AUTHORS +=head1 AUTHOR Ricardo SIGNES Erjbs@cpan.orgE diff --git a/lib/Parse/IRCLog/Result.pm b/lib/Parse/IRCLog/Result.pm index 95600ce..daf9792 100644 --- a/lib/Parse/IRCLog/Result.pm +++ b/lib/Parse/IRCLog/Result.pm @@ -4,12 +4,20 @@ package Parse::IRCLog::Result; use strict; use warnings; -our $VERSION = sprintf "%d.%03d", q$Revision: 1.2 $ =~ /(\d+)/g; - =head1 NAME Parse::IRCLog::Result -- results of parsing an IRC logfile +=head1 VERSION + +version 1.101 + + $Id$ + +=cut + +our $VERSION = '1.101'; + =head1 SYNOPSIS use Parse::IRCLog; @@ -66,7 +74,7 @@ Provide iterator functionality. Five minutes of looking didn't find a mixin class for iterators, so I might end up just delegating iterator methods to a tied array object or something. This can wait. -=head1 AUTHORS +=head1 AUTHOR Ricardo SIGNES Erjbs@cpan.orgE