grrrrr.....

Peter Scott peter at PSDT.com
Mon Oct 21 19:23:31 CDT 2002


At 05:09 PM 10/21/02 -0700, nkuipers wrote:
>Could someone please explain to me the how-to of grouping modules in a
>namespace.  Here's the situation.
>
>I have two modules written, one called Blaster.pm and one called Basic.pm.
>They were originally placed in the same folder as a driver script for
>Basic.pm.  The driver contained the lines
>
>BEGIN { push @INC, '/home/nkuipers/code';

use lib qw(/home/nkuipers/code);

>use Basic;
>my $dnaobj = Basic->new();
>
>And worked beautifully.
>
>Then I put both modules in a different folder, BIO.
>
>I've diddled with the begin block to reflect the new path, ie.,
>/home/nkuipers/code, home/nkuipers/code/, .../BIO, .../BIO/, etc.  I've
>diddled with the use statment, ie., use Basic, use BIO::Basic, use ... ().
>I've diddled with the constructor call, ie., ...BIO::Basic->new(),
>Basic->new().  Nothing works.  Depending on the combination of diddling, it
>dies with a "Cannot locate package BIO::Basic, @INC contains...BEGIN 
>failed at
>compile time", or "Can't locate object method "new" via package "BIO::basic"
>or even "Undefined subroutine at &main::get_count called at driver line 14."
>I realize this is not informative since it doesn't match error to 
>combination,
>but who cares what I'm doing wrong, how is it done right.  What's the missing
>idiom here?

The package declaration must match the use statement.  i.e.,

use BIO::Basic;

looks in @INC for BIO/Basic.pm, which should start with

package BIO::Basic;

Get that right and you'll be fine.  It's a long way down the road 
before you might want to consider alternatives.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/




More information about the Victoria-pm mailing list