Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: Readonly oddity

by dmitri (Priest)
on Jan 27, 2016 at 15:49 UTC ( #1153761=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^6: Readonly oddity
by zwon (Abbot) on Jan 27, 2016 at 22:12 UTC
    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2021-10-21 19:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (83 votes). Check out past polls.

    Notices?