On Jul 18, 1:20 am, [EMAIL PROTECTED] (Jack Minoshima) wrote:
> Hi.
> Please allow me to ask another silly question.
>
> I wrote the program and it works fine.
>
> --------------------------------------------------------------------
> Animal.pm
> package Animal;
> use Exporter;
> @ISA = qw(Exporter);
> @EXPORT = qw(speak);
> sub speak {
>  print "I speak!\n";}
>
> 1;
>
> ----------------------------------------------------------------------
> Mouse.pm
> package Mouse;
> use Animal;
> @ISA = qw(Animal);
> @EXPORT = qw(speak sound);
> sub sound {
>  print "the sound!\n";};
>
> 1;
>
> ------------------------------------------------------------------------
> farm.pl
> use Mouse;
> speak;
> sound;
>
> C:\Documents and Settings\jackm\usetest>farm.pl
> I speak!
> the sound!
>
> but when I change Mouse.pm to replace "use Animal and set @ISA" with use
> base, it won't work.
>  ----------------------------------------------------------------------
> Mouse.pm
> package Mouse;
> use base qw(Animal);
> @EXPORT = qw(speak sound);
> sub sound {
>  print "the sound!\n";};
>
> 1;
>
> C:\Documents and Settings\jackm\usetest>farm.pl
> Can't call method "sound" on an undefined value at Animal.pm line 10.
>
> Please someone kindly let me know why?
> Thank you very much in advance.
> I'm using;

use base qw(Animal);
is equivalent to:
BEGIN { @ISA = qw(Animal); }

It doesn't relieve you of the necessity of using the module in the
first place. You still have to
use Animal;

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to