Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^11: Constant subroutine main::C redefined

by tobyink (Canon)
on Sep 10, 2012 at 22:43 UTC ( [id://992869]=note: print w/replies, xml ) Need Help??


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

Well, if you want constant folding, then you'll have to deal with the warning being generated. It's a mandatory warning.

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

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^12: Constant subroutine main::C redefined
by BrowserUk (Patriarch) on Sep 10, 2012 at 23:47 UTC
    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

      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'
      $ 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://992869]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2025-11-12 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (68 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.