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; }