in reply to Accessing Methods of Another Package
update: Or you could keep a reference to the Section2 object which might be a better method OO wise.package Module::Main ... sub init { my $self = shift; $self->{SEC1} = Module::Section1->new($self); $self->{SEC2} = Module::Section2->new($self); return 1; } package Module::Section1; sub new { my $class = shift; my $parent = shift || die; #require a parent.. my $self = {}; $self->{PARENT} = $parent; bless($self,$class); return $self; } sub do_something { my $self = shift; $self->{PARENT}->{SEC2}->method(); return; }
|
|---|