open(INFILE, "linecount.txt") my @hold; while () { push(@hold, $1)&& last if (m/$thefileIamLookingfor/); } $value = join(' ', @hold); my( $file, $linecount) = split(/~/, $value);