Hi Monks,
I have a code in a package called Device.pm
sub new {
my ($class,$device,$serveraddr,$port) = @_;
my $self = {};
bless ($self,$class);
$self = {
'device' => $device,
'serveraddr' => $serveraddr,
'port' => $port
};
THe same module, needs to take care of creating an object of another package, for this I need to pass the values of serveraddr and port, how do I do that ?
for ex, (I know this is wrong,I get Global Symbol $self,$serveraddr,$port requires explicit package name error)
my $SockObj = Communication->new( $self->{$serveraddr}, $self->{$port}
+);
Communication.pm inturn contains
sub Communication::new {
my $class = shift;
my ($addr, $port) = @_;
my $socket = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $addr,
PeerPort => $port,
) or die "couldn't connect: $!";
$socket->autoflush();
return bless $socket, $class;
}
Any advice would be very helpful.
Thanks,
Perllace