Gossamer Forum
Quote Reply
@ISA
From what I understand, if I have loads of modules, and don't want to write $x = &Module::Subroutine("input");, then at the top of the script, I can just write @ISA = qw(Module);, and use VARS qw(@ISA); and it will look for the sub in that module. Only it doesn't work. What am I doing wrong?

Paul? Alex?


I understand that it controls inhertiance, so if i wanted I could do @ISA = qw(Higher::Class); and everything in it would be overridden.

Last edited by:

Forum Bot: Sep 6, 2002, 4:12 PM
Quote Reply
Re: [Forum Bot] @ISA In reply to
Hi,

ISA is only for inheritance and object oriented programming. You are making a function call which doesn't go through the same method dispatching that class/object methods do.

As a simple fix, try:

Module->Subroutine("input");

instead. This will get treated like a class method.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] @ISA In reply to
Quote:
As a simple fix, try:

Module->Subroutine("input");

instead. This will get treated like a class method.

It's then probably worth pointing out too that the class name gets passed in as the first argument to "Subroutine" so he'll need:

Code:
sub Subroutine {

shift;
my $input = shift;

To get rid of the class or:

Code:
sub Subroutine {

my $class = shift;
my $input = shift;

if ($input eq "something") {
$class->error();
}

.....to save it and be able to call other class methods.

Last edited by:

Paul: Sep 7, 2002, 2:08 AM
Quote Reply
Re: [Paul] @ISA In reply to
Thanks, Alex and Paul, for your helpful answers.