package Foo::DBIWrapper; use strict; sub new { my $class = shift; my $dbh = shift; my $self = { _dbh => $dbh }; bless $self, $class; } sub dbq { my $self = shift; my $sql = shift; my $sth = $self->prepare($sql); # don't use the _dbh! $sth->execute(@_); # added @_ for any binding return $sth; } our $AUTOLOAD; sub AUTOLOAD { my $self = shift; (my $func = $AUTOLOAD) =~ s/.*:://; if (my $coderef = $self->{_dbh}->can($func)) { unshift @_, $self; goto &$coderef; } die "Can't $AUTOLOAD in $self"; } 1;