Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to correctly use a symbolic reference to automatically generate hash names?

by dsheroh (Parson)
on Mar 05, 2014 at 10:33 UTC ( #1077060=note: print w/ replies, xml ) Need Help??


in reply to How to correctly use a symbolic reference to automatically generate hash names?

The code you posted should probably work, provided that use strict 'refs' is not in effect.

This is because you're trying to use symbolic references (Perl's term for "a variable that contains the name of another variable") and using symbolic references is one of the things that strict is specifically intended to prohibit.

This is because symbolic references are a bad idea in any circumstance where you might need to someday debug or maintain the code.

Any time that you find yourself making a series of variables named var1, var2, var3, etc., that's a pretty sure sign that you really want an array rather than a list of variables with similar names. This applies just as much to hashes and arrays as it does to scalars.


Comment on Re: How to correctly use a symbolic reference to automatically generate hash names?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2014-08-30 16:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls