Just got my copy of Perl Best Practices and I'm trying to figure out the author's "rule" for subroutine parameter passing. If it's spelled out somewhere, I can't find it, so please point me at the correct page and I'll leave you alone.
If not, here is the source of my confusion. On page 12 there is a bolded code example:
my @candidates = get_candidates($marker);
Which leads me to believe he doesn't want spaces after or before the parens. For example, he likes the above better than:
my @candidates = get_candidates( $marker );
However, on page 13, there are lines like this:
chomp( $record );
my ($name, $votes) = split("\t", $record);
substr($name, 0, 10);
So the "rule" appears to be: "If it's a built-in, don't add spaces, except if there's only one argument, then do add spaces. If it's user-defined, don't add spaces, even if there is only one argument." Except, then I found one on page 29 that was even worse:
add_step( \@steps, $next_step, $elapsed_time);
I also find it disconcerting that the author advocates putting spaces for "complex" hash keys, like
$foo = $var{ $names{$i} }, but not for code blocks in things like grep and map:
grep {defined $_} @something; (and actually on page 17 I see
map { sqrt $_ } @results; so maybe this is just an accidental inconsistency).
So maybe I'm being picky, but my company is now trying to identify a coding standard for all our programmers to use, and at the beginning of the chapter I was hoping I could just point to this and say, "we should use this, it's clearly documented, there's reasoning behind each recommendation, and other good perl programmers coming on board will have a high liklihood of being previously exposed to it."
Am I looking at typos which will be fixed in the next version of the book or is this issue something that's generally not explicitly defined in most coding standards?
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.