@rows = split(/\n/,$stats); ... $rowcount = scalar(grep {defined $_} @rows);