eXile has asked for the wisdom of the Perl Monks concerning the following question:
This code is called from Fiets.pm like this:package Fiets::Cache; use strict; use warnings; ... sub new { my ($self,$class)=@_; my $cdir = Fiets::getvar('cachedir'); if ($cdir) { use Cache::FileCache; use base qw(Cache::FileCache); $self=Cache::FileCache->new({ 'cache_root' => $cdir, 'default_expires_in' => '4 h' }); } else { use Cache::NullCache; use base qw(Cache::NullCache); $self=Cache::NullCache->new({ 'default_expires_in' => '4 h', }); } bless ($self,$class); return $self; } ... 1;
Fiets.pm and $Fiets::cache are used in my main-program, and other libraries in the Fiets::-hierarchy.use Fiets::Cache; our $cache=Fiets::Cache->new();
If I change the two-argument bless into bless($self), these errors disappear and in the debugger I can see (with 'm') that my Fiets::Cache indeed has its own new method and a couple of other methods of it's own and inherits a whole bunch of methods for Cache::Cache.'Can\'t locate object method "get" via package "main"'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why is a 2-argument bless not working in my situation
by tedrek (Pilgrim) on Mar 31, 2004 at 01:27 UTC | |
|
Re: 2-argument bless not working?!
by runrig (Abbot) on Mar 31, 2004 at 01:27 UTC | |
by eXile (Priest) on Mar 31, 2004 at 01:44 UTC | |
by djantzen (Priest) on Mar 31, 2004 at 10:48 UTC | |
|
Re: why is a 2-argument bless not working in my situation
by Vautrin (Hermit) on Mar 31, 2004 at 04:31 UTC | |
by Hofmator (Curate) on Mar 31, 2004 at 09:00 UTC | |
|
Re: 2-argument bless not working?!
by Sandy (Curate) on Mar 31, 2004 at 01:53 UTC |