or download this
my $sql = "insert into foo (name,value) values (?,?) returning id into
+ ?";
my $sth = $dbh->prepare($sql);
...
$sth->bind_param_inout(2, \$id, 1024); # this is a reference that gets
+ written to!
$sth->execute;
print $id; # or whatever... $id has been written into by the execute