Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

AUTOLOAD -- deprecated, in relation to inherited method/function

by Sifmole (Chaplain)
on Jun 29, 2004 at 18:51 UTC ( [id://370575]=perlquestion: print w/replies, xml ) Need Help??

Sifmole has asked for the wisdom of the Perl Monks concerning the following question:

All, I have been stumped by this one for a while, and was hoping you all could help. I have a pair of classes, the second inherits from the first -- like this:
package Foo::Bar; use strict; use Exporter; use vars qw( @ISA @EXPORT_OK ); @ISA = qw(Exporter); @EXPORT_OK = qw(&doSomething); sub new { blah blah blah... } sub dosomething { blah blah blah }
package Foo::Bar::Blah; use strict; use Foo::Bar qw(doSomething); use vars qw( @ISA ); @ISA = qw(Foo::Bar);
Now in (sample) code I have the following:
use strict; use Foo::Bar::Blah; Foo::Bar::Blah::doSomething('xyz');
I get the following error:
Use of inherited AUTOLOAD for non-method Foo::Bar::Blah::doSomething() + is deprecated at ./tests/testFooBarBlah.pl ... Can't locate auto/Foo/Bar/Blah/doSomething.al in @INC ...
This doSomething() function is intended to be able to be called as either a method of an instance or a straight function call. If I call it like:
Foo::Bar::doSomething('xyz');
There is no issue reported, and it appears to function properly.

Can anybody shed some light on this?

Note: this is using perl 5.8.2

Replies are listed 'Best First'.
Re: AUTOLOAD -- deprecated, in relation to inherited method/function
by Fletch (Bishop) on Jun 29, 2004 at 19:04 UTC

    As with any perl error message you can look it up in perldoc perldiag (or add use diagnostics; to your code, or pipe stderr through the splain utility). There's an explanation and a workaround for this therein.

Re: AUTOLOAD -- deprecated, in relation to inherited method/function
by dragonchild (Archbishop) on Jun 29, 2004 at 18:59 UTC
    The following works for 5.8.0 on RH9 threaded.
    In Foo.pm package Foo; use strict; use warnings; use Exporter; our @ISA = qw( Exporter ); our @EXPORT_OK = qw( foo ); sub foo { print "Foo\n"; } 1; ---------- In Bar.pm package Bar; use strict; use warnings; use Foo qw( foo ); our @ISA = qw( Foo ); sub bar { foo() } 1; ---------- In test.pl #!/usr/bin/perl use strict; use warnings; use Bar; Bar::foo(); Bar::bar();

    *shrugs*

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://370575]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-03-28 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found