my $num; while (m#Results\s+[\d,]+\s+thru\s+[\d,]+\s+of\s+([\d,]+)?\s*$#) { $num=$1; last if defined $1 or eof; $_.=<>; } # value, if any, in $num