use strict; use warnings; while () { print "email $2, $3, code $1.\n" if /]: ([a-f0-9]+):.*?said: (\d+) <(.+?)>/i; }