skip date lines that are NOT followed by to|from|connect
#!/usr/bin/perl use strict; use warnings; my $datestr = ""; while (<DATA>) { if (/^.{15}$/) { $datestr = $_; next; } if (/^(.?connect\sto.*|to=.*|host.*)$/) { print $datestr; } print; $datestr = ""; } __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 +1f975b124c9b1b12499b11974d1d44 +099f4d135f440c46d305d...) 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)
Output:
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 +1f975b124c9b1b12499b11974d1d44 +099f4d135f440c46d305d...) 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)
In reply to Re: a regexp?
by almut
in thread a regexp?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |