Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^3: Readonly oddity

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

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

> I personally don't like constant because it is not suitable for any complex structures

For example?

Replies are listed 'Best First'.
Re^4: Readonly oddity
by kcott (Bishop) on Jan 27, 2016 at 06:11 UTC

    The documentation for constant explains this.

    "For example?"

    The NOTES section of that documentation has an example.

    — Ken

      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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2021-10-28 15:01 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (96 votes). Check out past polls.