in reply to Regexes, stitching broken lines, and other fun stuff.

Another, fairly simple way: since your data is so regular, and since all the elements are delimited by whitespace, you can simply parse it as a list of sets.

#!/usr/bin/perl -w use strict; open Spg, '<', 'spg.txt' or die "spg.txt: $!\n"; my @list = split /\s+/, do { local $/; <Spg> }; close Spg; while (@list){ # Output 1 and 5... print "@list[1,5]\n"; # ...and throw away the first 7 splice @list, 0, 7; }

--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf