$uniqueid= time . $$; my $sql <do($sql); $sql="SELECT a,key from FOO where a=$uniqueid; my $sth=$dbh->prepare_cached($sql); $sth->execute(); my $cursor = $sth->fetchrow_hashref; my $id=$cursor{"key};