This header section contains a bunch of left-justified lines that are all shorter than 60 characters. Only the headers and summary lines are interesting. Col1 Col2 Col3 Notes ---- ---- ---- ------------- 1 123 123 Foo bar baz 2 741 200 Barbaz Foobar 3 100 0 Boofar fazboo Total: 323 Next header section, etc. #### my @extract; while (<$INF>) { # Ignore useless lines next if length($_) > 60; next unless /^(\w|\s*Total:)/; push @extract, $_; } # Now you can process @extract for the interesting stuff print @extract;