#!/usr/bin/perl -w use strict ; my $filename = 'sample.dat' ; open (DATAFILE, "<$filename") or die "$0: cannot open file \"$filename\" for reading: $!\n" ; my (@record, @records) ; while () { tr/\r\n//d ; push @record, $_ ; if (@record == 11) { push @records, join ("\t", @record) ; @record = () ; } } close (DATAFILE) ; die "$0: incomplete record (line count = ", scalar @record, ") at end of file \"$filename.\"\n" unless @record == 0 ;