Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Constant subroutine main::C redefined

by tinita (Parson)
on Sep 10, 2012 at 11:55 UTC ( #992734=note: print w/ replies, xml ) Need Help??


in reply to Constant subroutine main::C redefined

put
no warnings "redefine";
before the redefinition.
this does not work from "outside", e.g. for

no warnings "redefine"; # won't help here require Foo; delete $INC{"Foo.pm"}; require Foo;


Comment on Re: Constant subroutine main::C redefined
Select or Download Code
Re^2: Constant subroutine main::C redefined
by BrowserUk (Pope) on Sep 10, 2012 at 11:58 UTC
    no warnings "redefine";

    Doesn't work for constant subroutines. Yes. It is an unusual requirement to redefine a constant ;)


    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

      like I said, it doesn't work from outside. for constants the redefinition happens in constant.pm.
      you could delete $main::{C}

        Also note that "redefining" a constant does not necessarily do what BrowserUk wants. The constants get inlined, so redefining them only works from that point on:

        use constant C => 1; sub c { C }; use constant C => 2; sub d { C }; print c(); # 1 print d(); # 2
        like I said, it doesn't work from outside. for constants the redefinition happens in constant.pm.

        I'm not using the constant pragma.


        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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-12-26 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls