package testfilter; use strict; use warnings; use DBI; use base qw( HTTP::Proxy::HeaderFilter ); sub init {my ($self) = @_; # Connect to the database.and store the reference in the hash my $dbh = DBI->connect("dbi:mysql:woo",'swoo','password', {'RaiseError' => 1}); my $inth = $dbh->prepare( q{INSERT INTO foo (id, name) VALUES (?, ?)}); $inth->execute("1","jim"); $self->{INSERT} = \$inth; } sub filter { my ( $self, $headers, $message ) = @_; my $inth = $self->{INSERT}; $inth->execute("2","tom"); my $dbha = DBI->connect("dbi:mysql:woo",'woo','password', {'RaiseError' => 1}); my $intha = $dbha->prepare( q{INSERT INTO foobar (id, name) VALUES (?, ?)}); $intha->execute("1","$self->{INSERT}"); } 1;