use warnings; use strict; my @nums; while () { if (/ (\d+) \s+ (\d+) \s+ \| /x) { push @nums, $1, $2; } } print "file1 @nums"; __DATA__ start of tree ------------------ Da | something > 1234: 1 (81.06/25.89) Number of Items : 15 Size of the Store : 30 something else here === Summary Matrix === a b <-- classified as 11111 222 | a = 0 3333 444 | b = 1