in reply to Variable Names and References

Rule 1: Every time you want to create a variable whose name is decided at runtime, you really want to use a hash;

Rule 2: If you think you know better, you are wrong;

Rule 3: No, really

Replies are listed 'Best First'.
Re^2: Variable Names and References
by Sartan (Pilgrim) on Mar 12, 2007 at 15:55 UTC
    Against rules 1-3, I always sorta thought of a pointer/reference to a hash object as basically a hash(with certain perks). There don't really seem to be void-ish references.
    Perl creates a runtime error if you take
    $hash = {}
    and try to dereference it as an array or anything else(er well hashes and arrays are about it) such as
    @$hash.
    Perl seems to think a reference to a hash is still a hash but wants to protect the user a bit in terms of nasty memory issues.
    Doing $hash->{ $key } basically acts just like a hash object with slightly different syntax. So $hash->{ 'runtime' . $key } seems like a normal progression.
    D