in reply to Re: regex for perl script
in thread regex for perl script

Almost; but that will retain the ',' after the IP-address; use
split /, /
instead.

Paul

Replies are listed 'Best First'.
Re^3: regex for perl script
by Anonymous Monk on May 15, 2011 at 20:14 UTC
    Thanks for you feedbacks dude. I'm sorry to say that i'm unable to fit the code into the script. I'm novice to perl. Here's the full script:

    I've another dovecot log file which also logs login info. If the script extract rip from this log that's also fine:
    2011-05-15 16:10:10 pop3-login: Info: Login: user=<test@example.com>, +method=PLAIN, rip=180.234.57.184, lip=166.165.52.15 2011-05-15 16:10:11 POP3(test@example.com): Info: Disconnected: Logged + out top=0/0, retr=0/0, del=0/0, size=0 2011-05-15 16:10:14 pop3-login: Info: Login: user=<test@example.com>, +method=PLAIN, rip=180.234.57.184, lip=166.165.52.15 2011-05-15 16:10:15 POP3(test@example.com): Info: Disconnected: Logged + out top=0/0, retr=0/0, del=0/0, size=0 2011-05-15 16:10:17 pop3-login: Info: Login: user=<test@example.com>, +method=PLAIN, rip=180.234.57.184, lip=166.165.52.15 2011-05-15 16:10:18 POP3(test@example.com): Info: Disconnected: Logged + out top=0/0, retr=0/0, del=0/0, size=0

      I was done reading at "dude."


      Dave

        I've got it working with this regex format: $pat = '^(\d\d\d\d-\d+-\d+ \d+:\d+:\d+) (?:imap|pop3)-login: Info: ' . 'Login: .*? (?:\[|rip=):f*(\d+\.\d+\.\d+\.\d+)[],]'; Thank you.

      Too much code.

      Which section of code is having the problem?