use strict; use warnings; while () { print "email $2, $3, code $1.\n" if /]: ([a-f0-9]+):.*?said: (\d+) <(.+?)>/i; } #### __DATA__ Jul 6 14:36:41 moe postfix/smtp[15107]: A73DC113B63: to=, relay=adamant.concentric.com[207.155.248.168], delay=17, status=bounced (host adamant.concentric.com[207.155.248.168] said: 554 : Recipient address rejected: Unknown or invalid user oetiker@concentric.com (in reply to RCPT TO command)) email 554, oetiker@concentric.com, code A73DC113B63.