Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Confused by some var names in perlref

by DouglasDD (Sexton)
on Dec 05, 2018 at 16:35 UTC ( #1226776=perlquestion: print w/replies, xml ) Need Help??

DouglasDD has asked for the wisdom of the Perl Monks concerning the following question:

I don't think I'm understanding the Perl docs on Not-so-symbolic references
In the section I've copied below, shouldn't they say $hash (because of the {}s) instead of $array to make things less confusing?
Similarly, because of all the subscripting that is done using single words, the same rule applies to any bareword that is used for subscripting a hash. So now, instead of writing
$array{ "aaa" }{ "bbb" }{ "ccc" }
you can write just
$array{ aaa }{ bbb }{ ccc }

Replies are listed 'Best First'.
Re: Confused by some var names in perlref
by Eily (Monsignor) on Dec 05, 2018 at 16:51 UTC

    The Perl Glossary states:

    An unordered association of key/value pairs, stored such that you can easily use a string key to look up its associated data value. This glossary is like a hash, where the word to be defined is the key and the definition is the value. A hash is also sometimes septisyllabically called an “associative array”, which is a pretty good reason for simply calling it a “hash” instead.
    So if you want to really confuse people you can pretend a hash is just kind of weird array that stores pairs of element rather than scalars, and ignores the concept of ordering. If you manage to use the word "septisyllabically" somewhere while doing that it's even funner!

    But beyond that, yes, that piece of code is misleading at best

      I understand that it is much to late to change, but I would have preferred the name "associative array" because it describes the function of the structure. "Hash" may be more descriptive to the developers of perl, but to the rest of us, it is an implementation detail.

      You seem to have found a bug in the glossary. If the word "septisyllabically" is correct, a definition should be provided. Neither nor offer much help.


        I don't think associative array is a good name either. Depending on which language you come from array might mean "ordered list" to you, and I don't think the "associative" in the name would be of any help if you don't know the concept in the first place.

        Other languages have other names for hash-like objects, like map (eg C++), which because of the map keyword would be a pretty bad idea in perl (I must admit that I had a lot of trouble understanding map precisely because I only knew the world as meaning "hash-like object" when I learned perl). Some languages have dictionaries, or dict (like python), which isn't a bad name I suppose. For what it's worth, in raku (perl 5's little sister) the association feature can be implemented either by using the base type hash, or an object implementing the Role "Associative".

        If the word "septisyllabically" is correct, a definition should be provided.
        It's a neofrankenlogism, with a latin prefix, a greek root and -ally for adverbing that indicates the use of an heptasyllabe (and if my jokes still don't help, it means "with seven syllabes"). It's consistent with the spirit of perl's documentation and, as far as I can tell, Tim Toady's interest in linguistic related subjects. I guess it might be a little unhelpful for new comers though.

        "septisyllabically" was probably an intentional neologism, in an attempt to be clever: "septi" from "septum", which is Latin for "seven", "syllabi" from "syllable", "ically" = "in the manner of": ie, "it's a seven-syllable way of saying 'associative array'" ('associative array' does indeed have seven syllables)

Re: Confused by some var names in perlref
by roboticus (Chancellor) on Dec 05, 2018 at 16:49 UTC


    Yep, that can certainly be confusing. While using a more descriptive name is better than 'array' or 'hash', using 'array' for a hash, and 'hash' for an array is even worse!


    When your only tool is a hammer, all problems look like your thumb.

Re: Confused by some var names in perlref
by LanX (Archbishop) on Dec 05, 2018 at 16:53 UTC
    you are right, looks like a typo.

    Probably someone changed the example from array to hash and forgot to adapt the var name.

    Just file a perlbug with a diff correcting it.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice


      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
        Thanks, you rock!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1226776]
Approved by marto
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2019-06-26 00:29 GMT
Find Nodes?
    Voting Booth?
    Is there a future for codeless software?

    Results (108 votes). Check out past polls.