Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

How do you pronounce variable names?

by jflevi (Beadle)
on Feb 18, 2008 at 15:57 UTC ( [id://668579] : perlquestion . print w/replies, xml ) Need Help??

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

I feel kinda stupid asking this, but it has bugged me for a long time.
I learned what I know of Perl by myself, with the help of a few books (the Llama really got me started), so I have no clue as how to "pronounce" (in English) things like $somescalar, @odds, $_, etc.
Do you say "dollar sign somescalar", "at odds", "dollar sign underscore" ? These lenghty expressions seem un-perly to me.

Thanks ,,,


Replies are listed 'Best First'.
Re: How do you pronounce variable names?
by johngg (Canon) on Feb 18, 2008 at 16:09 UTC
    An interesting question, hadn't really thought about it before. I think I say "dollar fred" for $fred, "at odds" for @odds, "percent seen" for %seen etc. I definitely say "dollar underscore" for $_ but I'm getting a sort of Heisenberg effect as I consider the others so I'm a bit unsure.



Re: How do you pronounce variable names?
by jrtayloriv (Pilgrim) on Feb 18, 2008 at 16:30 UTC
    I normally don't say the punctuation at all. I say "scalar somescalar", "array odds", "default variable" (yes, I know -- "default for what?", "it's not the default variable for everything, why do you call it that?!?!",etc ... but most of the time, people seem to know what I'm talking about, so it's what I call it) -- this makes it much clearer when both talking about it, and thinking about it.

    It becomes more handy especially when dealing with references -- @$stuff would not be "at symbol dollar sign stuff", but would be "array referred to by stuff" (since all references are scalars, it's implicit that if it's referring to something, it's a scalar).
Re: How do you pronounce variable names?
by kyle (Abbot) on Feb 18, 2008 at 16:16 UTC

    I say "$" as just "dollar", not "dollar sign". When I'm talking about punctuation variables, I name the punctuation marks, but sometimes use the English names (e.g., "input record separator" instead of "dollar slash").

    Other variables, I think I just drop the sigil half the time. It's "some scalar", and "odds".

    Mostly, though, I just don't talk in code. I write it—in emails, in chats, here, and in the software I'm writing.

Re: How do you pronounce variable names?
by ikegami (Patriarch) on Feb 18, 2008 at 16:47 UTC

    If I'm showing code to someone, there's usually no need to pronounce the sigil at all (e.g. "friends has 2 elements"). I'd probably be more likely to say "scalar" and "array" for "$" and "@" in this situation. I might even call the variable by its value instead of by its name (e.g. "Then I 'draw' the circle." for $form->draw()).

    If I'm dictating code, completeness and clarity is important, so I'd specify the symbols by name (e.g. "dollar friends equal 2 semicolon.").

      Ok, I'll bite. When and under hat circumstances are you "dictating" code?

      holli, /regexed monk/
        When I'm writing code using Microsoft Speech Recognition. It goes something like this:
        me: my dollar sign t=1; computer: my dolls are singing tequila 1 semi goin;

        I'm not really a human, but I play one on earth. Cogito ergo sum a bum
        Yes, inquiring minds need to know. (Interviews, perhaps?)
        When discussing or teaching syntax
Re: How do you pronounce variable names?
by CountZero (Bishop) on Feb 18, 2008 at 17:40 UTC
    In the Perl course I teach, it is definitely "scalar somescalar", "array odds", "hash table", ... and also "scalar underscore" and "array underscore", which nicely links them together as a "defaulty" type of variables.

    Things like $odds[3] and $table{'John'} become "the scalar element with index 3 of the array odds" and "the scalar element with key 'John' of the hash 'table'". I know it is a bit long in the mouth, but it is a course for Perl newbies.


    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: How do you pronounce variable names?
by Joost (Canon) on Feb 18, 2008 at 17:05 UTC
Re: How do you pronounce variable names?
by goibhniu (Hermit) on Feb 18, 2008 at 16:31 UTC

    My habits are pretty much the same as Kyle's (should I be worried?).

    The only thing I have to add is that $_ is so common that it's gotten shortened to "dollar-under" in my head. The cool thing is that Perl still understands me when I don't fully pronounce the "underscore".

    #my sig used to say 'I humbly seek wisdom. '. Now it says:
    use strict;
    use warnings;
    I humbly seek wisdom.
Re: How do you pronounce variable names?
by moklevat (Priest) on Feb 18, 2008 at 18:22 UTC
    FWIW, based on what I picked up in the computer lab in the late 1980s, I used to always read $somescalar as "string somescalar". Now, after some effort to re-learn it, I read it as "scalar somescalar" most of the time. After looking up some old punctuation poetry it appears that "dollar" was the common idiom back then, so I guess I have no idea where "string" came from in my lexicon.

    Update:Apparently I learned it from BASIC, though that would have been much earlier than the late 80s, but it stuck.

      Probably from BASIC. Early versions required String field names to start with a $ (ie $a, $bc, etc.) If it didn't, it was assumed numeric and you usualy ended up with a letter that resulted in a zero. This is from MBASIC, circa 1975. Also, field names were limited to only two characters back then, and if they started with i thru r they were considered integer, otherwise floating. How did we ever survive? ;-)
        In every BASIC I'm familiar with, the $ came at the *end* of the variable. And this thread reminds me of a thread I started many years ago in comp.lang.perl.misc about pronunciation. Much of the advice there is good, the obvious error being to pronounce the # sign as "pound".

      I used to call "$" "string" because that's what it was called in BASIC. A string variable FOO$ was read, "foo string".

Re: How do you pronounce variable names?
by Anonymous Monk on Feb 18, 2008 at 16:55 UTC
    Usually I don’t pronounce the sigils: “some scalar”, “odds”.

    I make an exception for variables with short names: “dollar underscore”.

    I pronounce everything if I am reciting a perl script over the phone. (Don’t laugh, this happened to me last summer. I went on holiday without net access, a server died in my absence, my colleagues needed guidance on how to make the spare server work, in lieu of remembering how to use the find command I wrote a perl script. With pen and paper and lines I numbered myself.)

Re: How do you pronounce variable names?
by saberworks (Curate) on Feb 18, 2008 at 17:28 UTC
    It's "money" somescalar!
Re: How do you pronounce variable names?
by dsheroh (Monsignor) on Feb 18, 2008 at 18:32 UTC
    In the broadest terms, I generally don't pronounce my code at all. I just write it.

    If something has a real name, I tend to call it by that name and I choose names accordingly (e.g., singular nouns for scalars, plural nouns for arrays/hashes). In cases where it may be ambiguous, I'll pronounce the sigil as the normal character, with the one oddity that, unless I'm paying attention, I have a tendency to pronounce $ as "hex" instead of "dollar". (My first programming experiences were with Apple ][s, where hexadecimal numbers were writen as "$E8".)

    For punctuation variables, there's not much choice but to read off the string of characters literally, although, as another oddity, I generally pronounce _ as "sub", making $_ "hexub" ("hex-sub"). Fortunately, I speak in Perl rarely enough that I've never yet encountered a situation where it was ambiguous whether "sub" meant the _ character or the sub keyword...

Re: How do you pronounce variable names?
by ilcylic (Scribe) on Feb 18, 2008 at 22:06 UTC
    Maybe I'm weirder than the rest of these monks, but I admit that when I'm reading or writing code, I end up "pronouncing" the code in my head. Just like when I'm typing plain old text. (No, my lips don't move when I read. ;) )

    I use "dollar", "at" and "hash". I'm not sure why the two syllable option is ok for scalars, and not hashes, but that's just what's in my head.

    "for space paren at foo paren space brace space space print dollar underscore semicolon space space brace return return"

    is basically what runs through my head when I type out:

    for (@foo) { print $_; }
Re: How do you pronounce variable names?
by Anonymous Monk on Feb 18, 2008 at 16:19 UTC
    variables - scalars, arrays and hashes
Re: How do you pronounce variable names?
by Fletch (Bishop) on Feb 19, 2008 at 19:32 UTC
Re: How do you pronounce variable names?
by smithers (Friar) on Feb 20, 2008 at 03:56 UTC
    To hear the proper pronunciation, download the audio-book version of "Programming Perl" from ;)
Re: How do you pronounce variable names?
by chatur (Acolyte) on Feb 19, 2008 at 13:14 UTC
    same problem with ~

    now no problem it's tilda
      ~ is pronounced squiggle - like SKWIG-ULL. (in my experience.. tilde just doesn't seem to get used as much)
        I think that's the first time I've heard that one. I use "tilde" or the type of operator (e.g. ~~ would be "smart match").