while ( ) { my @line = split( /\t/, $_ ); while ( @line ) { my @four_records = splice( @line, 0, 4 ); # think "4 x shift( @line )" push @array_of_arrays, [ @four_records ]; # make this an array containing an array of four elements in each array slot. } }