While you are correct, I like to keep to what I think are best practices in my regular coding.
For me this means
attempting to maintain consistancy of style across a codebase
utilizing idioms as much as possible (unless using another mechanism provides better readability)
attempting to do as much I/O as possible at once to minimize waiting for a resource to become available again
scoping my variables as tightly as possible, and if they are needed elseware returning a reference to the data as opposed to the data
So from my angle of best practices, its a natural extension to only request the pieces of data I am actually going to do something with. If I only need the month from localtime I do
my $mth = ( split(/\s+/, localtime) )[1];
I dont need the other values, so why waste the RAM and cycles building the lvalue list only to use a single element? Granted here its slightly contrived, but in more complex code, only building what I need, and returning only what is essential tends to turn out a more maintainer friendly codebase in my personal experience.
Update: I don't know that I was clear in how I make the jump to only capture the data I'm going to use, based on the list above. I try to keep the codebase trim, as the more keystrokes the easier for a bug to creep in (yay strict, warnings, boo logic errors :P). So from there, its an extension to keep the number of variables down. I guess I should also add judicious use of comments to my best practices list. I comment blocks, and particularly interesting lines (ala, splitting some value and pulling elements, I will generally to something like # 0: foo 1: bar 2: baz).
MMMMM... Chocolaty Perl Goodness.....
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.