If using DBI, use the rows method
my $sth = $dbh->prepare(q{...});
$sth->execute(@bound_variables) or die $dbh->errstr;
print "Rows = " . $sth->rows;
As @ThisSuitIsBlackNot pointed out, this may not work, so if you're pulling all of the records, just count the data structure:
print "Rows = " . scalar @{$var1->{reference}};