in reply to regex for perl script

Things like "The regex syntax provided there is not working for me actually" (without even given the regex that is not working) and "i'm unable to fit the code into the script" (followed by 643 lines of code you have not written yourself), will not get you any useful answer here.

Why don't you contact the author of that code?

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: regex for perl script
by Anonymous Monk on May 16, 2011 at 13:13 UTC
    I've got it working.
    '^(\d\d\d\d-\d+-\d+ \d+:\d+:\d+) (?:imap|pop3)-login: Info: ' . 'Login: .*? (?:\[|rip=)[:f]*(\d+\.\d+\.\d+\.\d+)[],]';
    Thanks.
      Just in case the regex gets crazy on you, fall back to Text::CSV::Simple.
      #!/usr/bin/perl use strict; use warnings; use Text::CSV::Simple; use Data::Dump qw(dump); my $logfile = "/root/Desktop/ip.log"; my $parser = Text::CSV::Simple->new; $parser->want_fields(2); my @data = $parser->read_file($logfile); print dump(@data);