in reply to a regexp?
#!/usr/bin/perl use strict; use warnings; use strict; use warnings; my $lastDate; my $printing; while (<DATA>) { if (/^\w+\s\d+\s\d+:\d+:\d+\s*$/) { $lastDate = $_; $printing = undef; next; } if ($printing) { print; next; } next if ! $lastDate; if (! /^(?:to|from|connect)\b/) { $lastDate = undef; next; } print $lastDate, $_; $printing = 1; $lastDate = undef; } __DATA__ to=<colossus1821@juno.com>, relay=mx.dca.untd.com[64.136.44.37]:25, delay=177323, delays=177322/0.02/1.8/0, dsn=4.0.0, status=deferred (ho +st mx.dca.untd.com[64.136.44.37] refused to talk to me: 550 Access denied...0b30748490a5c4c48900e4e9912059c0e18d1d24dd45d1896d5150b1f1755 +1f975b124c9b1b12499b11974d1d44099f4d135f440c46d305d...) Mar 21 18:58:08 Mar 21 18:58:08 Mar 21 18:58:08 to=<scottw@webav.com>, relay=none, delay=187566, delays=187536/0.05/30/0, dsn=4.4.1, status=deferred (connect to webav.com[74.117.116.83]:25: Operation timed out) Mar 21 18:58:08 to=<stevew@webav.com>, relay=none, delay=187566, delays=187535/0.02/30/0, dsn=4.4.1, status=deferred (connect to webav.com[74.117.116.83]:25: Operation timed out) Mar 21 18:58:08 Mar 21 18:58:08 to=<ssams@phoenixformations.com>, relay=none, delay=187576, delays=187546/0.02/30/0, dsn=4.4.1, status=deferred (connect to mail.phoenixformations.com[69.61.147.50]:25: Operation timed out)
Prints:
Mar 21 18:58:08 to=<scottw@webav.com>, relay=none, delay=187566, delays=187536/0.05/30/0, dsn=4.4.1, status=deferred (connect to webav.com[74.117.116.83]:25: Operation timed out) Mar 21 18:58:08 to=<stevew@webav.com>, relay=none, delay=187566, delays=187535/0.02/30/0, dsn=4.4.1, status=deferred (connect to webav.com[74.117.116.83]:25: Operation timed out) Mar 21 18:58:08 to=<ssams@phoenixformations.com>, relay=none, delay=187576, delays=187546/0.02/30/0, dsn=4.4.1, status=deferred (connect to mail.phoenixformations.com[69.61.147.50]:25: Operation timed out)
|
|---|