This does not capture all you wanted but perhaps you can build on this:

#!/usr/bin/perl use strict; use warnings; my $log=q<10.25.95.100 ab - [05/Aug/2003:12:00:30 -0700] "GET /creativ +e/2|2127274-1>; # note 1 (re above) # print "\$log is $log \n"; # note 2 if ( $log =~ / (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) # capture IP digits \s[a-z]{2,2}\s-\s\[ # match but don't capture spa +ce, dash, space (\d+\/[A-Z][a-z]{2,2}\/\d{4,4}) # capture the date : # don't capture the perlimina +ry colon (\d+:\d+:\d+\s-\d{4,4}) # capture time with colons &a +mp; GMT offset (.*) # dot-slash deprecated, but c +apture to end /x ) { # extended notation, end cond +it, print print "\$1=$1, \$2=$2, \$3=$3, \$4 = $4 \n"; # note 3 } else { print "no matches\n"; } # note 4
... balance of code (Update: ...as corrected in other nodes and restoring the full original string to $log/$s)

1 "$s" may be less than clear, a few hundred lines later; use a meaningful name for the $var
2 I read this as OP's simple test to make sure the assignment above worked.
3 It would be better to make this
 print "IP = $1, DATE = $2, TIME= $3"and so on, if you're merely testing your regex
4 added the conditional: ALWAYS test captures before trying to use them


In reply to Re: search pattern not terminated by ww
in thread search pattern not terminated by habel_k

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.