use v5.12.0;
use warnings;
use Data::Dump qw/pp dd/;
use DBI;

my $DBG = 0;

while ( my ($class, $meths) = each %DBI::DBI_methods ) {
    while ( my ($method, $info) = each %$meths ) {
        my $fullmeth = "DBI::${class}::$method";
        say "$fullmeth: ".pp $info->{U}[2]
          if $DBG
            and ($info->{U}[2]//"") =~ /\@bind_params|\$statement|\@args/
#            or $fullmeth =~ /execute/
            ;
        #DBI->_install_method($fullmeth, 'DBI.pm', $info);
    }
}

# --- patch method
$DBG=1;


my $execute_old = \&DBI::st::execute;
*DBI::st::execute =
  sub {
      if ($DBG ){
          warn "calling execute (",pp(\@_),")";
          warn pp '$_[0]->{Statement}: ', $_[0]->{Statement};
          warn pp '$_[0]->{private_ROLF}: ', $_[0]->{private_ROLF};


      }
      my @args = $execute_old->(@_);
  }
  ;




my $driver = 'mysql';
my $db     = 'perl_test';
my $host   = '127.0.0.1';
my $port   = '3306';


my $dsn  = "dbi:$driver:database=$db;host=$host;port=$port";
my $user = 'perl_test';
my $pwd  = 'perl_test';

my $dbh =
  DBI->connect($dsn, $user, $pwd,
               { RaiseError => 1, AutoCommit => 0 });

my $first= "Rolf";

my $statement = <<"__SQL__";
SELECT *
    FROM USERS
    WHERE First = ?
;
__SQL__

#tie $statement, "Tie::Scalar";


my $sth = $dbh->prepare($statement) or die "ERROR prepare";

 $sth->{private_ROLF} ="Rolf";


$sth->execute($first) or die "ERROR execute";

pp $sth->fetchall_hashref('Id');

$dbh->disconnect;
