in reply to How to send attributes of an object to create an object of another class?

I know this is wrong...

It's right, but it's only right within a method where $self is an instance of Device. This means you have to write something like:

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();