in reply to Suppressing Subroutine redefined warning

How are they defining the same subroutines? Are they defining subs in the same namespace, e.g. main? If so, that's probably not a good idea. If possible, you should have each package define the subs in its own namespace, and then use a classname to access the subs in one namespace or the other. Like so:

# Backend::A package Backend::A; sub foo { } 1;
# Backend::B package Backend::B; sub foo { } 1;
# main my $backend = 'Backend::A'; require $backend; $backend->foo(); # then later, if necessary: $backend = 'Backend::B'; require $backend; $backend->foo();
We're building the house of the future together.

Replies are listed 'Best First'.
Re^2: Suppressing Subroutine redefined warning
by philcrow (Priest) on Mar 27, 2006 at 20:22 UTC
    They are mixins which define subs in the same packages, but not main. I agree that that would be a bad idea.

    It's possible I could be talked out of my mixin scheme, but it would take you a lot of effort. Explaining why would also be a lot of effort, which I will avoid, at least for now.

    Phil

      The warnings pragma is lexical. If you don't want the 'redefine' warnings, you have to say so in the mixin classes themselves.

      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
        Thanks, that is correct.

        But, I don't want to remove the warnings in all cases. So, I'll do a bit of redesign to mind my namespace manners a bit better.

        Phil