*** 2007-08-17 08:30:51 *** [UID] = 030318520070817083011 followed by information, including line breaks and empty lines, repeat of the same 21-digit number, etc. *** 2007-08-17 09:25:17 *** [UID] = 030104220070817092407 Reason = Web server error *** XML Request *** more data, line breaks, spaces, etc. #### $badxml = `cat /mmf/log/BadXMLXact*`; $badxml =~ /@ARGV[0](.|\n)+/; $& =~ m/\*\*\*.*UID/; $output = $`; for ($output ) { s/\s{3,}/\n/g; } print $output; #### perl -00 -nle 'print if /21-digit-number(.|\n)+(\*\*\*\.*UID)/'