Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^4: Readonly oddity

by kcott (Bishop)
on Jan 27, 2016 at 06:11 UTC ( #1153728=note: print w/replies, xml ) Need Help??

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

The documentation for constant explains this.

"For example?"

The NOTES section of that documentation has an example.

— Ken

Replies are listed 'Best First'.
Re^5: Readonly oddity
by dmitri (Priest) on Jan 27, 2016 at 15:49 UTC
    You mean the array reference example? It only says that you can change the values, not that it's "not suitable." It's quite suitable, I use it all the time.
      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.

        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.
        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?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2021-10-28 02:03 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (95 votes). Check out past polls.