Reputation: 2089
I have in my base class use Storable qw/nfreeze thaw/;
but I cannot access nfreeze
in my child class. I am calling it in child class like nfreeze($data)
.
Thanks.
Upvotes: 0
Views: 120
Reputation: 118595
Storable::nfreeze
and Storable::thaw
are functions and not methods -- they do not expect an object of a particular type or a package name as their first arguments. In general, you call these subroutines directly (nfreeze($data)
) rather than with indirect syntax ($obj->thaw()
) and so you should not expect them to be in the set of inherited methods.
To use these functions in your child class, import them into your child package
package ChildClass;
use Storable qw/nfreeze thaw/;
or call the functions with their fully qualified subroutine names:
Storable::nfreeze($data);
BaseClass::thaw($data);
The second call works because nfreeze
/thaw
would have already been imported into the BaseClass
namespace.
Upvotes: 4