my $cnt = 0; open (FILE,$filename)||die "Cannot open $filename\n$!\n"; while($cnt<5){ $header = ; } # now we can go through the records... while(){ ... } close (FILE);