Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I'm trying to create a read-only "multi-dimensional" constant using the built-in constant pragma. I know that there's the Readonly module (amongst others), but I'm trying to stick to basics. Using anonymous list references doesn't really work, because they can be modified, as documented: Even though a reference may be declared as a constant, the reference may point to data which may be changed, as this code shows. Okay, so I'll use some sort of indirection, I thought, and came up with something like this: … but, this doesn't quite do what I expected. Output: I was under the impression that constants are really subs that I could take the reference of, but this doesn't seem to be the case. Alternatively, I've tried taking direct references, but this is... just merging the lists (which is obviously bad to begin with and what I wanted to avoid by using references) in a weird "reference all elements individually" way: leading to
Is there any proper way to do this? In reply to Multi-dimensional constants by Ionic
|
|