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

Ola,
I'm writing a package in which I use another package situated in the same namespace (and included in the same archive).
Assume:
Foo::Bar (Foo/Bar.pm) Foo::Bar::Baz (Foo/Bar/Baz.pm)
Foo::Bar uses Foo::Bar::Baz. That's ofcourse not the problem. The problem lies in getting it all in the same archive.
h2xs made me some nice stubs but I can't seem to get it all working. I'm sure I need to add some options to my Makefile.PL but no luck.
While testing Foo::Bar, Foo::Bar::Baz can't be located.

Oh yes, did I mention both packages are in the same archive? Below my current Makefile.PL (which obviously is missing bits...
use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Foo::Bar', 'VERSION_FROM' => 'Bar.pm', # finds $VERSION 'PREREQ_PM' => { 'LWP::Simple' => '1.35', 'HTML::TokeParser' => '2.24', }, 'dist' => {COMPRESS=>'gzip',SUFFIX=>'gz'}, );
Any Makefile.PL guru present? please step forward

Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.

Replies are listed 'Best First'.
Re: Packages & Makefile.PL
by mattriff (Chaplain) on Apr 14, 2002 at 16:24 UTC
    The Makefile.PL you posted for Foo::Bar seems basic enough and fine to me.

    Do you also have a Makefile.PL for Foo::Bar::Baz in the subdirectory with Baz.pm? It sounds like you might not, and you need it for this to work.

    If you create a Makefile.PL for each module, ExtUtils::MakeMaker will recurse and find each of them when you run "perl Makefile.PL" from the top-level directory.

    After that, Foo::Bar should see Foo::Bar::Baz when "make test" is run.

    - Matt Riffle

      Do you also have a Makefile.PL for Foo::Bar::Baz in the subdirectory with Baz.pm? It sounds like you might not, and you need it for this to work.

      Actually you don't. You need just the one Makefile.PL See my answer below. If you don't believe me get CGI::Simple and have a look at the structure. This uses one Makefile.PL and installs CGI::Simple CGI::Simple::Utils CGI::Simple::Cookie and CGI::Simple::Standard

      When in doubt see how someone else has done it and R&D (Ripoff and Duplicate)

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Packages & Makefile.PL
by tachyon (Chancellor) on Apr 14, 2002 at 18:23 UTC

    All you need is this structure:

    Foo-Bar-0.01/Bar.pm Foo-Bar-0.01/Makefile.PL Foo-Bar-0.01/MANIFEST Foo-Bar-0.01/Changes Foo-Bar-0.01/test.pl Foo-Bar-0.01/README Foo-Bar-0.01/Bar/Baz.pm # in Bar.pm package Foo::Bar; # in Baz.pm package Foo::Bar::Baz; # in Makefile.PL WriteMakefile( 'NAME' => 'Foo::Bar',

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Packages & Makefile.PL
by chromatic (Archbishop) on Apr 14, 2002 at 16:51 UTC
    What happens if you create a 'lib/' directory and move both modules under there as appropriate?
(crazyinsomniac: MANIFEST) Re: Packages & Makefile.PL
by crazyinsomniac (Prior) on Apr 15, 2002 at 09:06 UTC