in reply to Inheritance problem: Not a HASH ref
Furl is implemented as a reference to a reference, not as a reference to a hash. This makes adding fields to it a bit harder.
The easier way would be to delegate to it instead of inheriting from Furl:
package XYZ; use strict; use warnings; our $VERSION = 1; use parent 'Furl'; sub new { my $class = $_[0]; my $furl = Furl->new(); my $self = { furl => $furl, }; bless($self, $class); # rebless to our own class # setting some own data in self: $self->{'debug'} = 1; $self->{'ABC'} = 42; return $self }
This of course means that you will need to implement all "inherited" methods from Furl as stubs in your class:
for my $method (qw(get put whatever)) { *$method = sub { my $self = shift; $self->{furl}->$method( @_ ); } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inheritance problem: Not a HASH ref
by bliako (Abbot) on Feb 25, 2019 at 18:39 UTC | |
by NetWallah (Canon) on Feb 25, 2019 at 19:17 UTC | |
by bliako (Abbot) on Feb 26, 2019 at 13:16 UTC | |
by bliako (Abbot) on Feb 26, 2019 at 14:03 UTC | |
by tobyink (Canon) on Feb 26, 2019 at 17:08 UTC | |
by bliako (Abbot) on Feb 26, 2019 at 21:56 UTC | |
| |
by bliako (Abbot) on Feb 25, 2019 at 19:40 UTC | |
by stevieb (Canon) on Feb 25, 2019 at 23:28 UTC |