open my $fh => "linecount.txt" or die "Open linecount.txt: $!"; my ($file, $linecount); while (<$fh>) { ($file, $linecount) = split /\s*~\s*/; last if $file && $file eq $thefileIamLookingfor; }