Here's my try:

#!/usr/bin/perl -w use strict; my $data = 'Jul 30 19:39:06 server pure-ftpd: (user@68.158.32.189) [NOTICE] /home/shows//Genesis/Genesis 1978-06-24 FLAC/genesis1978-06-24-prefm-d1t04.flac downloaded (71074015 bytes, 60.83KB/sec) Jul 30 19:39:23 server pure-ftpd: (user@68.17.66.125) [NOTICE] /home/shows//Simon and Garfunkel/Simon and Garfunkel 2003-10-16/SG2003-10-16-d2t03.shn downloaded (2075533 bytes, 115.25KB/sec)'; my @result = $data =~ / ^(\w+)\s # month ($1) (\d+)\s # day ($2) ([\d:]+) # time ($3) .*?\((\w+) # user ($4) \@ # @ ([\d.]+?)\)(?:.|\n)*? # ip ($5) \[.+?\].*? # [NOTICE] until matching: (\/(?:.|\n)+?) # file ($6) until matching: (?:\s downloaded) # space and downloaded (?:.|\n)*? # optional dot or \n until matchin +g: \((\d+\s bytes) # size ($7) .+?([\d.]+KB\/sec)\) # speed ($8) /mxg; foreach (@result) { $_ =~ s/\n//; print $_, $/; print "\n" if $_ =~ /\/sec/; # separate entries } __END__ __OUTPUT__ Jul 30 19:39:06 user 68.158.32.189 /home/shows//Genesis/Genesis 1978-06-24 FLAC/genesis1978-06-24-prefm-d +1t04.flac 71074015 bytes 60.83KB/sec Jul 30 19:39:23 user 68.17.66.125 /home/shows//Simon and Garfunkel/Simon and Garfunkel 2003-10-16/SG2003 +-10-16-d2t03.shn 2075533 bytes 115.25KB/sec


In reply to Re: Pure Ftpd log regex by Dietz
in thread Pure Ftpd log regex by redhotpenguin

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.