in reply to subroutine xyz redefined at ...

let me clarify:

I found out that there is a CPAN version of A.pm, which is used by the base package of B.pm
I guess loading two different packages with the same package-name give me this warning!

So, the questions is, can this be solved ? I get the impression that eval doesn't do this!

I can of course do:
use A ; my $result = `doSomething.pl` ; # doSomething.pl uses B.pm ....

Replies are listed 'Best First'.
Re^2: subroutine xyz redefined at ...
by kennethk (Abbot) on Aug 24, 2009 at 17:44 UTC
    So when B.pm loads A.pm, it overwrites everything that A.pm already put in the symbol table, and you get your error. Given that you can isolate code that uses A.pm explicitly from that which uses B.pm and success loading B.pm implies A.pm will load successfully, I think the simplest answer is to isolate the blocks of code from each other. For example:

    { use B ; # do stuff which only requires B } { use A; # do stuff which only requires A }
      testing your solution gives me the exact same warning!

      UPDATE: Also, the use statements are executed when the program starts, so the blocks around it do not influence which module is used. Depending on which is processed last, is used!
        Sorry, I assumed by controlling packages your issue would be resolved. After a little testing with some dummy modules (you have yet to specify which modules you are using), I've verified you can suppress the warning assuming it is resulting from uncontrolled exports from the modules. Since A.pm is exporting twice, you can prevent it from exporting any subroutines when you use it explicitly by modding your use statement to:

        use A qw();

        yielding a final code

        use A qw(); use B ; #.... do something