These are just examples but I think it's worth mentioning that these sort of names-

$str = 'abc'; $hash = {} $hash->{'key'} = 'val'; $array = []; push @$array, 'val'; # one of the few times you ever use a @ or a % print $array->[0];

-rankle -- me at least -- badly. The idea that a string should be named "string" and hash has to be named "hash," implies that either the variables are undocumented and going to be used in such a large scope that you'd have to go hunting to see where/how they were created or that the coder didn't think much about how the next hacker would read the program on a macro-level.

Variables are the most basic and easily mastered thing in a language besides math operators. When I inherit code with single letter variable names, or unintelligibly abbreviated ones which save four characters of typing, or those which describe the actual variable instead of its contents and purpose I curse the person who wrote it. Other hackers don't need help differentiating SCALAR from HASH -- at least not after the first few weeks :) -- they need help seeing what the code is supposed to be doing. Choosing good variable and sub names is one of the kindest things you can do for your fellow hackers.


In reply to Re: Only using scalers and references by Your Mother
in thread Only using scalers and references by stevesnz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.