Your regexes make it look like you are reading large portions of the log at one time (or maybe even slurping it?). Why?

If the log format is reliably consistent with the example you gave, a simple line-by-line reading should be plenty easy, quick and maintainable; and it looks like the kind of situation where a hash data structure would be handy:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @fieldnames = ( 'Team', 'Score', 'Player', 'Kills', 'Deaths', 'Team Kills', 'Suicides', 'Objective', 'Results for +Map' ); my $matchfield = join '|', @fieldnames; my %entry; my ( $map, $team, $player, $datafor ); while (<DATA>) { s/[\r\n]+//; # OS-neutral alternative to "chomp" my ( $timestamp, $data ) = unpack( "A26 A*", $_ ); next unless ( length( $data ) and $data =~ /$matchfield/ ); $timestamp =~ tr/[]//d; my ( $fieldname, $fieldval ) = split( /: /, $data, 2 ); $fieldname =~ s/^[\s*]+//; if ( $fieldname eq 'Results for Map' ) { processEntry( \%entry ); %entry = (); $entry{map} = $fieldval; $entry{time} = $timestamp; } elsif ( $fieldname eq 'Team' ) { $datafor = $fieldname; $team = $fieldval; $entry{$team} = {}; } elsif ( $fieldname eq 'Player' ) { $datafor = $fieldname; my $uid; ( $player, $uid ) = ( $fieldval =~ /(\w+) .uid: (\w+)/ ); $entry{$team}{$player}{uid} = $uid; } elsif ( $fieldname eq 'Score' ) { if ( $datafor eq 'Team' ) { $entry{$team}{Score} = $fieldval; } else { $entry{$team}{$player}{Score} = $fieldval; } } else { $entry{$team}{$player}{$fieldname} = $fieldval; } } processEntry( \%entry ); sub processEntry { my $href = shift; return unless ( scalar keys %$href ); print Dumper $href; } __DATA__ [Thu Sep 21 17:48:38 2006] [Thu Sep 21 17:48:38 2006] ------------------------------------------ [Thu Sep 21 17:48:38 2006] Server started. [Thu Sep 21 18:37:22 2006] Client connected: Alpha [Thu Sep 21 18:37:31 2006] Client connected: Bravo [Thu Sep 21 18:38:20 2006] Client connected: Charlie [Thu Sep 21 18:39:18 2006] Client connected: Delta [Thu Sep 21 18:53:36 2006] [Thu Sep 21 18:53:36 2006] *** Results for Map: Worlds\ReleaseMultipla +yer\Bypass [Thu Sep 21 18:53:36 2006] [Thu Sep 21 18:53:36 2006] Team: Team 1 [Thu Sep 21 18:53:36 2006] Score: 93 [Thu Sep 21 18:53:36 2006] [Thu Sep 21 18:53:36 2006] Player: Alpha (uid: ad7023b7f46271acd31e1bd +287613b6d) [Thu Sep 21 18:53:36 2006] Score: 55 [Thu Sep 21 18:53:36 2006] Kills: 14 [Thu Sep 21 18:53:36 2006] Deaths: 15 [Thu Sep 21 18:53:36 2006] Team Kills: 0 [Thu Sep 21 18:53:36 2006] Suicides: 0 [Thu Sep 21 18:53:36 2006] Objective: 0 [Thu Sep 21 18:53:36 2006] [Thu Sep 21 18:53:36 2006] Player: Bravo (uid: 5fdcc95043dc4dac9d7b4af +b8469eb4f) [Thu Sep 21 18:53:36 2006] Score: 38 [Thu Sep 21 18:53:36 2006] Kills: 11 [Thu Sep 21 18:53:36 2006] Deaths: 17 [Thu Sep 21 18:53:36 2006] Team Kills: 0 [Thu Sep 21 18:53:36 2006] Suicides: 0 [Thu Sep 21 18:53:36 2006] Objective: 0

In reply to Re: regex issues with /gc in log analysis... by graff
in thread regex issues with /gc in log analysis... by EvanK

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.