Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^12: Constant subroutine main::C redefined

by BrowserUk (Patriarch)
on Sep 10, 2012 at 23:47 UTC ( [id://992872]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2025-11-15 00:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (72 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.