while ($line = ) { if ($line =~ /^\@\@client\#/) { # It's the start of a new client message - the header looks like this: # @@client#830759/HOSTNAME|1169985951.340108|10.60.65.152|HOSTNAME|sunos|sunos # Grab the hostname field from the header @hdrfields = split(/\|/, $line); $hostname = $hdrfields[3]; # Clear the variables we use to store the message in $msgtxt = ""; %sections = (); } elsif ($line =~ /^\@\@/) { # End of a message. Do something with it. processmessage(); } elsif ($line =~ /^\[(.+)\]/) { # Start of new message section. $cursection = $1; $sections{ $cursection } = "\n"; } else { # Add another line to the entire message text variable, # and the the current section. $msgtxt = $msgtxt . $line; $sections{ $cursection } = $sections{ $cursection } . $line; } }