Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^6: Readonly oddity

by zwon (Abbot)
on Jan 27, 2016 at 22:12 UTC ( [id://1153797]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Readonly oddity
in thread Readonly oddity

use 5.014; use strict; use warnings; use constant FOO => [ qw(BAR BAZ) ]; push @{FOO()}, qw(BOO HAHA); say join " ", @{FOO()}; @{FOO()} = split / /, "what are you using such constants for?"; say join " ", @{FOO()};
Oh, yeah, also I don't like that you have to add () to those constants in some cases.

Replies are listed 'Best First'.
Re^7: Readonly oddity
by BrowserUk (Patriarch) on Feb 01, 2016 at 22:11 UTC

    If that was a perceived as a real problem, it would be a pretty trivial fix to constant to have it apply the READOLY flag (per Internals::SetReadOnly()).

    The fact that no one has bothered probably means that most people don't bother to jump through the hoops required to modifiy constants.


    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". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^7: Readonly oddity
by dmitri (Priest) on Feb 01, 2016 at 20:14 UTC
    Well, obviously, don't do this. The idea is not to make it impossible to make modifications to FOO, but rather to make it stand out like a constant so that it gets used as a constant.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-20 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found