On Thu, Nov 15, 2001 at 08:22:51AM -0600, Jon Cassorla wrote:
> A.pm
> --------
> #!/usr/local/bin/perl
> package A;
> sub foo { print STDOUT "A::foo\n"; }
> sub bar { print STDOUT "A::bar\n"; }
> 1;
> 
> 
> B.pm
> --------
> #!/usr/local/bin/perl
> package B;
> our @ISA=qw(A);
> sub foo { print STDOUT "B::foo\n"; }
> 1;

[snip]
 
> But, if we change the inheritance line in B.pm to
>    our @ISA=qw(Root::B);
> 
> we get
> 
>       A::foo
>       A::bar
>       B::foo
>       Can't locate object method "bar" via package "B" at app.pl line
> 10.

This is because your package is still named 'B', by virtue of the package
statement in the file.  There is no such package as 'Root::B'.

The point I think you're confused on is thinking that the package statement
and @ISA elements are relative to their location on the filesystem.  They
aren't.  If you want to create a package Root::B you have to say 'package
Root::B'.  If you want to inherit from Root::A you have to say @ISA =
qw(Root::A).


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to