in reply to "use Foo.pm" twice from inside different packages...

There are two major problems:
  1. Bozo.pm never defines a namespace (package Bozo;) so it's defining its function in main::, not Bozo::
  2. Bozo.pm uses a lexical @EXPORT, not a package variable @EXPORT
Compare your code with this:
# Bozo.pm package Bozo; use Exporter; @Bozo::EXPORT = 'go_bozo'; sub go_bozo { return "bozo!" } 1;
# Foo.pm package Foo; use Bozo; sub proxy { return go_bozo() } 1;
# prog.pl use strict; use warnings; use Bozo; use Foo; print go_bozo(); print Foo::proxy(); # or Foo->proxy() if you want 'Foo' sent as the f +irst arg...

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: "use Foo.pm" twice from inside different packages...
by xdg (Monsignor) on Mar 02, 2006 at 22:14 UTC

    Just a minor note on the difference in our solutions with respect to Exporter: Perl 5.6 and earlier require Exporter to be subclassed, not just imported.

    use Exporter qw(import); # Perl >= 5.8 use base 'Exporter'; # Perl <= 5.6

    Even my solution isn't backwards-compatible prior to Perl 5.6 because I included our and warnings. For personal use, this may not matter, but module authors who plan to publish should keep it in mind.

    Update: For Perl >=5.8 I changed the example to note that you need to specify import.

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      D'oh, right, oops. (Editor's note: I said those words out loud as I typed them.)

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
      uh, our and use warnings work great in 5.6. I missed "prior to"
      Is there any reason to prefer "use Exporter qw( import)" instead of the backward-compatible "use base 'Exporter'" when running perl 5.8 anyway ?

      updated:we should use Exporter qw( import ) to get it to work :)

        I don't think there's much of a practical difference. It's shorter and it doesn't add anything to the @ISA array, meaning that there's a shorter inheritance tree for method resolution if you're doing a lot of multiple inheritance.

        I think the original subclassing approach was just a bad design choice, but now we're stuck with it if we want to be backwards compatible. But since that isn't an issue for some people (e.g. people writing specifically for desireable features of Perl 5.8, like Unicode), they have the option of moving to the better design.

        -xdg

        Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re^2: "use Foo.pm" twice from inside different packages...
by wazoox (Prior) on Mar 03, 2006 at 07:53 UTC
    As I said in my reply to xdg, the package definition actually may be optional, but obviously that's the wrong @EXPORT scoping that killed me :) Shame...
        Yes you're right... Well I'm getting confused with the good' ol' perl4 "require" too :)