jose_m has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I am trying to extract dates/times and email addresses from a log file. the format is like this: 2011-01-01 15:34:554 some words and numbers then email@host.com I would like to print the date, time, email address. I have something that is printing the email address but I cannot seem to be able to get the other 2 fields that i need. Kindly help when you get a moment. thanks, Jose. this is what i have
while (my $line = <>) { foreach my $output (split /\s+/, $line) { if ($output =~ /^[-\w.]+@([a-z0-9][a-z-0-9]+\.)+[a-z]{ +2,4}$/i) { print $output . "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: matching multiple patterns in one line
by toolic (Bishop) on Nov 18, 2015 at 17:49 UTC | |
|
Re: matching multiple patterns in one line
by james28909 (Deacon) on Nov 18, 2015 at 18:40 UTC | |
by james28909 (Deacon) on Nov 18, 2015 at 19:03 UTC | |
by AnomalousMonk (Archbishop) on Nov 18, 2015 at 19:55 UTC | |
by james28909 (Deacon) on Nov 18, 2015 at 21:03 UTC | |
by stevieb (Canon) on Nov 18, 2015 at 19:16 UTC |