Why does your Perl way involve cramming everything together, while your C way has whitespace around operators like =?
I dont tend to put a lot of whitespace in my subs. The "C way" wasnt written by me so I can't explain.
And why does your Perl way have strangeCaps?
Both have camelHumpIdentifiers. Its part of the original PM convention. Personally I hate it and would prefer perl_style_identifiers instead.
Iteration over @_ to just use its first element?
You didnt read the code very closely then, iteration over @_ occurs in both and is intended to convert all node_id's in the argument list into $NODE hashrefs. The fact that a return is generated from the first non $self argument is just an added utility. Imagine you might say:
my @ids=(1,2,3,4); getRef(@ids); printLog($_->{title}) for @ids;
Why are the curlies different?
I use cuddled else style curlies. Obviously the author of that nodes doesnt.
Im not really sure what your point here is. Sure my way isnt the only one, sure there are other ways that are still "the perl way". But clearly the first isnt one of them, or at least wouldnt normally be perceived as such.
Anyway, I think you totally missed the point. The point was that using proper Perl idiom you wouldnt go through all the extra work the original does to do what it is meant to do. And that for someone used to the idiom even realizing that the two code snippets are identical takes a bit of thinking. Or it did me anyway.
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
In reply to Re^2: The trouble with Perl Idiom
by demerphq
in thread The trouble with Perl Idiom
by demerphq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |