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 (Pope) 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.