my @data; my $curr; while () { $curr = $1, next if /^>DATA\s+SET\s+(\d+)/; push @{$data[$curr]}, $_; }