in reply to regex for perl script

You don't need a regex to extract the IP from that log, it's always in the same position
while(<$logfile>){ push @ip_addresses, (split / /, $_)[2]; }

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Replies are listed 'Best First'.
Re^2: regex for perl script
by rev_1318 (Chaplain) on May 15, 2011 at 17:25 UTC
    Almost; but that will retain the ',' after the IP-address; use
    split /, /
    instead.

    Paul

      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

        Too much code.

        Which section of code is having the problem?