in reply to Re^2: Overridding subroutines called in private subroutines
in thread Overridding subroutines called in private subroutines
would this do the same thing:
If you had been in main initially, yes.
Speaking of similar things, I didn't answer an earlier question.
sub Foo::Bar::f {}
is very similar to
{ package Foo::Bar; sub f {} }
But the code is compiled in a different package. This affects caller and other things:
use strict; use warnings; sub Foo::f { our $var; print(__PACKAGE__, "\n"); print("$var\n"); } { package Bar; sub f { our $var; print(__PACKAGE__, "\n"); print("$var\n"); } } $main::var = 'main!'; $Foo::var = 'foo!'; $Bar::var = 'bar!'; Foo::f(); # main # main! Bar::f(); # Bar # bar!
|
|---|