Good question, dreadpiratepeter - I suppose it's largely a matter of taste.   I only meant to preface my question with examples of my currently preferred naming style, not say that mine is necessarily better than any others.   I'm sure there are other threads on the matter, but only have time for a superficial Search, which turned up Sinister's recent Plural variable naming (or not?).

I forgot to ask the probably greater question that AM points out below - *why* would one choose to LABEL: a loop?

    cheers,
    Don
    striving toward Perl Adept
    (it's pronounced "why-bick")

Update: Now that I've a bit of time, I'll try to es'plain my naming preference of singular-for-a-hash-var:

It seems to boil down to what looks more clear in the context of how I most commonly employ the variable types in my code.   In the following bogo-code, each $hash{key} is dealt with as an individual (singular) item.

my %param = ( srcdir => '/home/me/perl/', destdir => '/root/perl/', moduledir => 'bar-foo', tarball => 'bar-foo.tgz', ); cd $param{srcdir}; system /usr/bin/tar $param{tarball} &param{moduledir} -zcvf and die $! +; system /bin/mv $param{tarball} $param{destdir} and die $!; cd $param{destdir}; system /usr/bin/tar $param{tarball} -zxvf and dir $!

Then in this next kind of hash usage, I still think of each $hash{key} as an individual item.   And in the loop, the "keys" conveys the plurality of $hash{key}'s within the greater %hash.   At least to me.   Heh.

my %info = ( ' script' => "$0", ' executable' => "$^X $]", ' hostOS' => "$^O", ' starttime' => "$^T", ); for (keys %info) { print $_ $info{$key}, "\n"; }


In reply to Re: (2) Thoughts on naming loop LABEL: (Why I name hash vars singular. Why label loops?) by ybiC
in thread Thoughts on naming loop LABEL: by ybiC

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.