BEGIN { # Auto-magically generate a number of similar functions without actually # writing them down one-by-one. This makes changes much easier, but # you need perl wizardry level +10 to understand how it works... my @simpleFuncs = qw(commit rollback errstr); my @stdFuncs = qw(do quote pg_savepoint pg_rollback_to pg_release); for my $a (@simpleFuncs){ no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict) *{__PACKAGE__ . "::$a"} = sub { $_[0]->checkDBH(); return $_[0]->{mdbh}->$a(); }; } for my $a (@stdFuncs){ no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict) *{__PACKAGE__ . "::$a"} = sub { $_[0]->checkDBH(); if($_[0]->{isDebugging}) {print STDERR $_[0]->{modname}, " ", $_[1], "\n";}; return $_[0]->{mdbh}->$a($_[1]); }; } };