in reply to Testing to INSERT or UPDATE MySQL record

Beside the other advices your code has several errors. Your update statement has no where clausel and act on all rows. Since there are no rows in the table execute work fine, but return 0e0. So there is no need to call insert.
my $r = $sth->execute(values %sql_data) or die "execute failed"; if ( $r == 0 ) { # do the insert }
Boris