package Device; sub create_communication { my $self = shift; return Communication->new( $self->{$serveraddr}, $self->{$port}; } package main; my $device = Device->new( 'device', 'localhost', 8080 ); my $communication = $device->create_communication();