Do you know where your variables are? | |
PerlMonks |
Re: Ref to a list not being equivalent to a list of refs to each elementby davido (Cardinal) |
on Jun 22, 2006 at 16:55 UTC ( [id://556950]=note: print w/replies, xml ) | Need Help?? |
That's an interesting quirk you've found. This discussion does present the opportunity to discuss the creation of constants. There's always the constant pragma, but it makes interpolation difficult and syntax confusing. There's your typeglob method, but the fact that *variable = \'value'; creates a sort of immutable constant is itself simply a side effect, easily forgotten unless one brushes up on the POD periodically. How about the use Readonly; solution?
It's clear, it states what it does explicitly, and it interpolates properly. Are there negatives to this approach? The ones I can think of are that not everyone will have Readonly.pm installed (but it's easy), and also, unless Readonly::XS.pm is also installed, the new readonly variables will incur a slight performance hit. Dave
In Section
Seekers of Perl Wisdom
|
|