sub putData { my $self = shift; my $sql = shift; my %param = @_; # get the statement handle my $sth = $self->dbh()->prepare($sql); # do the param binding for my $name (keys %param) { $sth->bind_param(":$name", $param{$name}); } # execute $sth->execute(); }