while( ) { next if $. < 5; chomp; next if ! length; last if /^END/; my @fields = unpack '(a7x)2a7', $_; # Do something with the fields. } #### my $record_start = 0; my @recs; while( ) { chomp; if( /^TABLE NAME/ .. /^END/ ) { # We're in a new record... if( /^TABLE NAME/ ) { $record_start = $.; push @recs, []; } next unless $. > $record_start + 3; # Skip header. next if ! length; next if /^END/; my @fields = unpack '(a7x)2a7', $_; # Do something with fields, such as... push @{$recs[-1]}, [@fields]; } }