Dear fellow monks, this time I'm done. This one should be obvious, easy, whatever, anyway I can't get it to work so I have to beg your help !
I reproduced easily what's wrong with a very tiny script and modules, so you can explain it easily because obviously there's some basic stuff I'm missing.. So here it is :

First the script, script.pl :
#!/usr/bin/perl use strict; use warnings; use lib '.'; use Bozo; print go_bozo();
Then there's of course the "Bozo.pm" module :
use strict; use warnings; # module Bozo use Exporter; my @EXPORT=qw( go_bozo); sub go_bozo { return "BOZO!\n" } 1;
OK, so THIS work exactly as I'd expect it to work. Now, the stuff that's driving me nuts, let's change the script and add an additional module :
#!/usr/bin/perl use strict; use warnings; use lib '.'; use Foo; print Foo->Foo();
Then the module Foo.pm (please be patient):
#!/usr/bin/perl use strict; use warnings; package Foo; use lib '.'; use Bozo; sub Foo { return go_bozo() } 1;
Fine, it still works! Now is coming whant I don't understand, just changing the script a little:
#!/usr/bin/perl use strict; use warnings; use lib '.'; use Bozo; use Foo; print go_bozo(); print Foo->Foo();
And now it doesn't work anymore : Undefined subroutine &Foo::go_bozo called at Foo.pm line 13. I understand what's wrong : i'm useing Bozo.pm twice, and that's certainly evil (well actually I don't se why, but never mind...). But why doesn't it give an error such as importing twice the same module at Foo.pm line 10 then ?
What advice could you please give me to manage the megatons of modules I have lying around (OO perl, here I come!) without getting nuts because I wrote use Bar once more than I should have in package #231?

In reply to "use Foo.pm" twice from inside different packages... by wazoox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.