|Perl Monk, Perl Meditation|
Polysignant variablesby scott (Chaplain)
|on Aug 06, 2001 at 00:34 UTC||Need Help??|
I just ran across the following bit of code in pudge's
journal on use Perl;
If the flag is true, then get the current value for the virtualuser. Cool. It is weird when you have been using perl for so long but use some feature for the first time.
So $VirtualUser changes it's meaning from 'do I want the virtual user' to 'the virtual user is'.
This caught my eye because I recently wrote a procedure in which a certain variable was first a string, then an array reference, and then a hash reference. While in this case the variable always signified the same thing (a header, FWIW) and so is 'monosignant' the type changed not once but twice ( polytypic? :), I thought perhaps I'd ask what other people think of these things.
Are your variables invariably monosignant and monotypic? Why or why not?
On one hand I don't see why they should be (mono-*) if the flow of the code suggests otherwise. On the other hand, I don't expect my variables to change type and so I may get quite confused when someone starts dereferencing what I was sure was a plain string. On the gripping hand, if I pay attention I should notice when said string becomes a hash ref, shouldn't I?
I just can't decide whether this is a Good Thing(tm) or not.
P.S. What do you think of 'polysignant'? Anyone got a better word for what I mean?