in reply to Re^11: Constant subroutine main::C redefined
in thread Constant subroutine main::C redefined

Of course, just because the warning will be generated; doesn't mean it has to be displayed. $SIG{__WARN__} can catch and hide it.

Really? What am I doing wrong then?

C:\test>perl -wE"$SIG{__WARN__}=sub{}; sub f(){1}; say f; sub f(){2}; +say f;" Constant subroutine f redefined at -e line 1. 1 2

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong

Replies are listed 'Best First'.
Re^13: Constant subroutine main::C redefined
by tobyink (Canon) on Sep 10, 2012 at 23:50 UTC

    The definition of the constants happens at compile time. The assignment to $SIG{__WARN__} happens at run time. You want it in a BEGIN block.

    perl -wE'BEGIN{$SIG{__WARN__}=sub{}}; sub f(){1}; say f; sub f(){2}; s +ay f;'
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re^13: Constant subroutine main::C redefined
by Anonymous Monk on Sep 10, 2012 at 23:56 UTC
    $ perl -wE"BEGIN{$SIG{__WARN__}=sub{};} sub f(){1}; say f; sub f(){2}; + say f;" 1 2