Being an extremely clueless newbie I wonder if the following approach will work for you.
#! BEGIN { # Convert the warning to Carp::cluck $SIG{__WARN__} = sub { Carp::cluck(@_); }; }; use Carp; use strict; use warnings; use Mod1; use Mod2; INIT { # Clear the warning to Carp::cluck $SIG{__WARN__}='DEFAULT'; }; sub One { # First definition return "first"; }; sub One { # Second definition return "second"; }; print One()."\n"; exit;
package Mod1; use Exporter; use strict; use warnings; @Mod1::ISA=qw(Exporter); @Mod1::EXPORT=qw(One); sub One { return "Mod1::One"; }; 1;
package Mod2; use strict; use warnings; use Mod1; @Mod2::ISA=qw(Exporter); @Mod2::EXPORT=qw(One); sub One { return "Mod1::One"; }; 1;
Running under Windows 2K/ActiveState 5.10 I get
C:\Code\SecCage>perl redef.pl Subroutine One redefined at Mod2.pm line 10. at redef.pl line 5 main::__ANON__('Subroutine One redefined at Mod2.pm line 10.\x +{a}') called at Mod2.pm line 10 require Mod2.pm called at redef.pl line 12 main::BEGIN() called at Mod2.pm line 10 eval {...} called at Mod2.pm line 10 Subroutine One redefined at redef.pl line 19. at redef.pl line 5 main::__ANON__('Subroutine One redefined at redef.pl line 19.\ +x{a}') called at redef.pl line 19 Subroutine One redefined at redef.pl line 23. at redef.pl line 5 main::__ANON__('Subroutine One redefined at redef.pl line 23.\ +x{a}') called at redef.pl line 23 second

In reply to Re: How to located cause of 'Subroutine SomeSubName redefined...' warnings by clueless newbie
in thread How to located cause of 'Subroutine SomeSubName redefined...' warnings by Anonymous Monk

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.