my $lastline; while (my $currentline = <$fh>) { chomp $currentline; my @tmp = split /\s+/, $row; ... $lastline = $currentline; }