my @fields; my $i = 0; while ( my $line = <$FILE> ) { chomp $line; if ( $line =~ /\t/ ) { if ($i > 0 ) { # do smth with last @fields array } @fields = split "\t", $line; $i++; } else { push @fields, $line; } }