|Just another Perl shrine|
Style: buried variables or double referencing?by punch_card_don (Curate)
|on Aug 20, 2005 at 14:18 UTC||Need Help??|
punch_card_don has asked for the wisdom of the Perl Monks concerning the following question:
Simple style question.
I have a count variable that is to be set depending on a condition:
Wherein '$some_variable' can have the values 'x' and 'y' only.
Coding the actual values right there in the conditonal effectively buries that way down in the bowels of a long program, but uses the minimum lines of code and is highly readbable once you find that snippet.
Setting two value holders at the top of the script make for easier maintenance when the values need to be changed some day:
but it creates double referencing and extra lines of code.
A third way would be to declare a hash:
Any feelings on which is preferable from a coding style and/or efficiency point of view?
Forget that fear of gravity,