Print the output of $myvar, I guess the ${1} interpolates in a way you don't expect it to.
BTW the line my $sth = $dbh->prepare($query) || die "Failed preparing the query. WTF?"; looks suspicious - || has a tight precedence, you should use or instead. Or just leave it, because the RaiseError option takes care of throwing an error.