in reply to Re: (Ovid) Re: Autoload'ed class method calls
in thread Autoload'ed class method calls

Read through his code and error message again. hackdaddy already has $AUTOLOAD declared properly, otherwise the first method call would fail, but according to hackdaddy, it's successful. However, read through the text of the actual error message.

Can't use string ("WM::Install::Table::ArchiveTbl") as a HASH ref whil +e "strict refs" in use at /u08/pkg/wms/wmcmtools/modules/WM/Install/Table/ArchiveTbl.pm line +192.

Now look at first few lines of the autoload.

sub AUTOLOAD { my ($self, $newval) = @_; $AUTOLOAD =~ /.*::get(_\w+)/ and $self->_accessible($1) and return $self->{$1};

As you can see, the return statement (return $self->{$1}) is attempting to use $self as a hashref. Since the error messsage shows that the programmers is trying to use the package name as a hashref, we clearly have the package name and not the object being passed as the first argument to AUTOLOAD. I was using a generic constructor to illustrate how the first argument could be a package name instead of an object, as expected.

Cheers,
Ovid

PS: I'm also a Terry Pratchett fan (I'm assuming that's what your nick refers to).

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.