Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How to located cause of 'Subroutine SomeSubName redefined...' warnings

by clueless newbie (Friar)
on Dec 11, 2010 at 15:08 UTC ( #876598=note: print w/ replies, xml ) Need Help??


in reply to How to located cause of 'Subroutine SomeSubName redefined...' warnings

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


Comment on Re: How to located cause of 'Subroutine SomeSubName redefined...' warnings
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://876598]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2014-09-22 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls