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