#! /usr/bin/perl use strict; # Assume a blank line to mean no whitespace $/ = "\n\n"; foreach my $record ( ) { chomp( $record ); my @data = split( "\n", $record ); # Take the last element of the last three lines in the record my $txname = ( split( / /, $data[ -3 ] ) )[-1]; my $txtime = ( split( / /, $data[ -2 ] ) )[-1]; my $errorcode = ( split( / /, $data[ -1 ] ) )[-1]; print "$txname\t\t\t$txtime\t\t$errorcode\n"; } __DATA__ Message Type: Name: Someone Time: Now Errorcode: 42 Message Type: Seismic instability Source: Japan Name: Anyone Time: Yesterday Errorcode: 23 Message Type: Author: Lewis Carrol Work: The hunting of whatever Name: Bellman Time: 12:32:1892 Errorcode: Snark!