use warnings; use strict; my @records; local $/ = "\n\n"; while () { my ($title, $row) = /TEST\s+\w+\W+(\w+)\D+(\d+)/; next unless defined $row; push @records, [$title, $row]; } print "$_->[0] -> $_->[1]\n" for @records; __DATA__ data per sample