I am creating a child class having base class as Net::SSH2. when I am trying to add a class variable I am getting error saying –
Not a HASH reference at F:\temp\fooA.pl line 17.
If I do the same thing wihtout Net::SSH2 then it works fine.
Here is the code :
use strict;
my $x = Foo->new();
package Foo;
use base qw (Net::SSH2);
sub new {
my ($class, %args) = @_;
my $self = $class->SUPER::new(%args);
$self->{'key'} = 'value';
bless $self, $class;
return $self;
}
It’s simple: Net::SSH2 doesnt return a hash ref, but a blessed scalar:
BTW: It’s always dangerous to rely on implementation details of third party code.
A possible solution would be to use inside out objects: