Sample code using the data you provided. Note that the required parameters are being extracted using a regex rather than split and that the name search code now uses index rather than a regex.

use strict; use warnings; my $search='\bconnected, address\b' ; my @users = qw(x3Oni Ramon Loly Mini Grasutza bullet Ad0n); my %R; print "search: @users\n"; while (<DATA>) { next unless /$search/o; s/L /:/; s/<.*>//; s/$search//o; s/ - /-/; my ($time, $name, $addy) = m!([-\d/:]*)\s*"([^"]*)"[^"]*"([^"]*)!; my $cleanName = name_match ($name); next unless $cleanName; my $nTime = fix_time ($time); my $rec = "$nTime $time $name"; if (! exists $R{$cleanName}) { $R{$cleanName} = $rec; next; } my ($t) = $R{$cleanName} =~ /^(\d+)/; $R{$cleanName} = $rec if $nTime > $t; } print "--------------------------\n"; my @values = sort values %R; foreach my $v (@values) { print STDOUT (split /:/, $v, 2)[1]; print "\n"; } # compare names, log names may have attributes; like sub name_match { my $test = shift; $test =~ tr/"//d; for (@users) { my $pos = length ($test) - length; my $at = index ($test, $_); return $_ if $pos == $at; } return ""; } # convert time from 'L: MM/DD/YYYY - hh:mm:ss' to YYYYMMDDhhmmss # which makes time comparison a doddle sub fix_time { local $_ = shift; s/.//; tr/://d; my($date, $time) = split /-/; my ($m, $d, $y) = split "/", $date; return "$y$m$d$time"; } __DATA__ L 03/31/2006 - 00:18:19: "smilE :) x3Oni<109><STEAM_ID_LAN><>" connect +ed, address "82.78.68.195:27005" L 03/31/2006 - 00:19:40: "smilE :) Ramon<110><VALVE_ID_LAN><>" connect +ed, address "86.55.92.11:27005" L 03/31/2006 - 00:23:06: "smilE :) Ramon<111><VALVE_ID_LAN><>" connect +ed, address "86.55.92.11:27005" L 03/31/2006 - 00:33:50: "smilE :) Ramon<112><VALVE_ID_LAN><>" connect +ed, address "86.55.92.11:27005" L 03/31/2006 - 00:35:09: "mT - Loly<113><STEAM_ID_LAN><>" connected, a +ddress "81.24.24.209:27005" L 03/31/2006 - 00:35:31: "mT - Mini^Me<114><STEAM_ID_LAN><>" connected +, address "81.196.153.50:27005" L 03/31/2006 - 00:36:42: "mT - Grasutza<115><STEAM_ID_LAN><>" connecte +d, address "81.24.24.207:27005" L 03/31/2006 - 00:38:05: "rrr<116><VALVE_ID_LAN><>" connected, address + "82.208.167.71:27005" L 03/31/2006 - 00:38:35: "rrr<117><VALVE_ID_LAN><>" connected, address + "82.208.167.71:27005" L 03/31/2006 - 00:41:03: "mT - kdt<118><STEAM_ID_LAN><>" connected, ad +dress "82.76.231.13:27005" L 03/31/2006 - 01:18:03: "smilE :) x3Oni<119><STEAM_ID_LAN><>" connect +ed, address "82.78.68.195:27005" L 03/31/2006 - 01:28:18: "astralis[mix] . bullet[A]<120><VALVE_ID_LAN> +<>" connected, address "86.106.193.40:27005" L 03/31/2006 - 01:28:43: "astralis[mix] . BNj-_-<121><STEAM_ID_LAN><>" + connected, address "81.24.24.227:27005" L 03/31/2006 - 01:30:10: "astralis[mix] . sUIFTI-_^<122><VALVE_ID_LAN> +<>" connected, address "84.247.25.70:27005" L 03/31/2006 - 01:31:30: "astralis[mix] . AD0n<123><STEAM_ID_LAN><>" c +onnected, address "85.120.80.131:27005"

Prints:

search: x3Oni Ramon Loly Mini Grasutza bullet Ad0n -------------------------- 03/31/2006-00:33:50: smilE :) Ramon 03/31/2006-00:36:42: mT - Grasutza 03/31/2006-00:38:35: rrr 03/31/2006-01:18:03: smilE :) x3Oni

I'm sure you understand now that you can replace the <DATA> with <FileHandleOfYourChoice> and that the contents of the users array can be filled from an external file too.


DWIM is Perl's answer to Gödel

In reply to Re^3: A pretty simple perl script.. by GrandFather
in thread A pretty simple perl script.. by xnd

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.