Your variable naming is quite strange. $self should be the object whose method you are writing, not some parameter. That is within the App package it's the application, within App::Widget it's the widget and within App::Widget::Menu it's the menu. And you, generally, should not access the insides of the App from within an App::Widget::Menu method.
If I understand things right, you pass an app to widget constructor and both app and widget to menu. so the code should be
package App; sub new { my ($class, %args) = @_; my $self = bless { %args }, $class; $self->{widget} = App::Widget->new( $self ); return $self; } package App::Widget; my( $class, $app ) = @_; my $self = bless { }, $class; $app->{menu} = App::Widget::Menu->new( $app, $self); return $self; } package App::Widget::Menu; sub new { my( $class, $app, $widget ) = @_; my $self = bless { }, $class; $app->{some_arg} = 1; $app->{menu}->BackgroundColor(222,222,222); return $self; }
Jenda
Enoch was right!
Enjoy the last years of Rome.
In reply to Re: Advice please on variable naming style in modules
by Jenda
in thread Advice please on variable naming style in modules
by isync
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |