# line 1 gen.pl use vlog; myblib::foo(1); myblib->foo(2); # foo(); # this would die - no foo() in main:: # bar(); # as would this package myblib; # temporarily switch package foo(3); package main; # switch back @ISA = qw(myblib); $a = bless do { \ my $x }, 'main'; $a->foo(4); # method lookup finds foo() in myblib:: # shoehorn the foo() function into main:: - that's roughly # what Exporter and 'use myblib qw(foo)' do *foo = *myblib::foo; foo(5); # now found in main:: $a->foo(6); __END__ myblib::foo(1) myblib::foo(myblib 2) myblib::foo(3) myblib::foo(main=SCALAR(0x818c688) 4) myblib::foo(5) myblib::foo(main=SCALAR(0x818c688) 6)