# added some debug output *DB::Handle::RapTTR::Test::real_new = \&DB::Handle::RapTTR::Test::new; *DB::Handle::RapTTR::Test::new = sub { print STDERR "CALLER (".join(',',caller()).")\n"; if (caller() eq 'RapTTR') { print STDERR "RETURNING REAL_NEW.\n"; ; return DB::Handle::RapTTR::Test->real_new; } print STDERR "RETURNING FAKE NEW.\n"; ; cluck "TRACE:"; return DB::Handle->new( connect_string => 'DBI:SQLite:dbname=./t/sqlite/rapttr', username => undef, password => undef ); }; #### TRACE: at t/comprehensive_3digbn_8digtid.t line 54 main::__ANON__('DB::Handle::RapTTR::Test') called at t/comprehensive_3digbn_8digtid.t line 50 main::__ANON__('DB::Handle::RapTTR::Test') called at /nfs/pdx/disks/nehalem.pde.077/projects/2.0_rapttr/RapTTR/blib/lib/RapTTR.pm line 688 RapTTR::download_pcd_revision('RapTTR=HASH(0x26931a0)') called at /nfs/pdx/disks/nehalem.pde.077/projects/2.0_rapttr/RapTTR/blib/lib/RapTTR.pm line 100 RapTTR::harness('RapTTR=HASH(0x26931a0)') called at t/comprehensive_3digbn_8digtid.t line 63 DBD::SQLite::db prepare failed: no such table: pcf_master at /nfs/pdx/disks/nehalem.pde.077/perl/5.12.2/lib64/site_perl/DB/Handle.pm line 165, line 2. prepare failed with DBI error (1):no such table: pcf_master at /nfs/pdx/disks/nehalem.pde.077/perl/5.12.2/lib64/site_perl/DB/SQL/Query.pm line 114 DB::SQL::Query::_prepare('DB::SQL::Query=HASH(0x29fa520)', 'DB::Handle=HASH(0x29fecf0)', 'SELECT job_name FROM pcf_master \x{a}WHERE revision = ?\x{a}') called at /nfs/pdx/disks/nehalem.pde.077/perl/5.12.2/lib64/site_perl/DB/SQL/Query.pm line 131 DB::SQL::Query::_init_sth('DB::SQL::Query=HASH(0x29fa520)') called at accessor sth defined at /nfs/pdx/disks/nehalem.pde.077/perl/5.12.2/lib64/site_perl/DB/SQL/Query.pm line 57 DB::SQL::Query::sth('DB::SQL::Query=HASH(0x29fa520)') called at /nfs/pdx/disks/nehalem.pde.077/perl/5.12.2/lib64/site_perl/DB/SQL/Query.pm line 85 DB::SQL::Query::execute('DB::SQL::Query=HASH(0x29fa520)', 216) called at /nfs/pdx/disks/nehalem.pde.077/projects/2.0_rapttr/RapTTR/blib/lib/RapTTR/Utils.pm line 571 RapTTR::Utils::get_rapttr_db_data('Job Name', 'DB::Handle=HASH(0x29fecf0)', 'SELECT job_name FROM pcf_master \x{a}WHERE revision = ?\x{a}', 216) called at /nfs/pdx/disks/nehalem.pde.077/projects/2.0_rapttr/RapTTR/blib/lib/RapTTR.pm line 699 RapTTR::download_pcd_revision('RapTTR=HASH(0x26931a0)') called at /nfs/pdx/disks/nehalem.pde.077/projects/2.0_rapttr/RapTTR/blib/lib/RapTTR.pm line 100 RapTTR::harness('RapTTR=HASH(0x26931a0)') called at t/comprehensive_3digbn_8digtid.t line 63 # Looks like you planned 24 tests but ran 2. # Looks like your test exited with 2 just after 2. #### prepare failed with DBI error (1):no such table: pcf_master at /nfs/pdx/disks/nehalem.pde.077/perl/5.12.2/lib64/site_perl/DB/SQL/Query.pm line 114 #### main::__ANON__('DB::Handle::RapTTR::Test') called at t/comprehensive_3digbn_8digtid.t line 50 main::__ANON__('DB::Handle::RapTTR::Test') called at /nfs/pdx/disks/nehalem.pde.077/projects/2.0_rapttr/RapTTR/blib/lib/RapTTR.pm line 688 #### use strict; use warnings; use lib 'C:\scripts'; package Foo; sub bar { print "I am bar from Foo.\n"; } package main; no warnings 'redefine'; *Foo::real_bar = \&Foo::bar; *Foo::bar = sub { print "I am bar NEW!\n"; Foo->real_bar; *Foo::bar = \&Foo::real_bar; }; &print_stuff; sub print_stuff { &print_bar1; &print_bar2; } sub print_bar1 { Foo->bar; } sub print_bar2 { Foo->bar; } #################### OUTPUT: plxc16479> $h2/scripts/tmp.pl # output from redefined sub I am bar NEW! # output from original sub called from inside redefined sub I am bar from Foo. # output from original sub after being redefined back I am bar from Foo. #### #! /usr/intel/pkgs/perl/5.12.2/bin/perl use strict; use warnings; package Foo; use Moose; package FakeFoo; use Moose; package main; no warnings 'redefine'; *Foo::real_new = \&Foo::new; *Foo::new = sub { if (caller() eq 'Bar') { print "Returning real Foo.\n"; return Foo->real_new; } print "Returning fake Foo.\n"; return FakeFoo->new; }; my $obj = Foo->new; print STDERR __PACKAGE__.": FOO IS (".ref($obj).")\n"; package Bar; $obj = Foo->new; print STDERR __PACKAGE__.": FOO IS (".ref($obj).")\n"; package Other; $obj = Foo->new; print STDERR __PACKAGE__.": FOO IS (".ref($obj).")\n";