in reply to Help with pattern matching

use warnings; use strict; my $str1 = 'Oct 9 08:50:53 mail_server sendmail[30172]: j99FopoN03017 +2: from=<support@symantec.com>, size=0, class=0, nrcpts=0, proto=ESMT +P, daemon=MTA, relay=[218.1.114.182]'; my $str2 = 'Oct 9 04:20:35 mail_server sendmail[20773]: j975sOqf03231 +2: to=<522-2204194-1-13-51954mpxas@dimexpress.com>, delay=2+05:26:11, + xdelay=00:00:00, mailer=esmtp, pri=19293815, relay=mail.xpress.com.' +; my $match = qr/relay=\[?([^\]]*)/; print "$1\n" if $str1 =~ $match; print "$1\n" if $str2 =~ $match;

Prints:

218.1.114.182 mail.xpress.com.

Perl is Huffman encoded by design.