my $check_inv_sql = "SELECT MAX(cdt) AS md FROM s_i ORDER BY cdt LIMIT 1"; $sth=$dbh->prepare($s_query) or die $dbh->errstr; $sth->execute; my $mt; if (my $hash_ref = $sth->fetchrow_hashref) { $mt = $hash_ref->{'md'}; print "$mt\n";#this returns below error } #### Use of uninitialized value $mt in concatenation (.) or string at Sb.pl line 56.