package Robo; use strict; use warnings; sub new { bless { Arm => Robo::Arm->new(), # 'Arm' points to instance of Robo::Arm Feet => Robo::Feet->new(), #'Feet' points to instance of Robo::Feet }, shift } 1; package main; my $robo = Robo->new(); $robo->{Feet}->walk(); $robo->{Arm}->pick( "Apple" ); #### sub walk { my $self = shift; $self->{Feet}->walk(); return; } sub pick { my ($self, $thing) = @_; return $self->{Arm}->pick( $thing ); }