[oak perl] A Simple Problem
Mark Bole
mark at bincomputing.com
Tue Mar 1 18:05:15 PST 2005
David Fetter wrote:
>On Tue, Mar 01, 2005 at 12:42:40PM -0800, Kester Allen wrote:
>
>
>>I like the module solution:
>>
>>use List::Util qw/sum/
>>@numbers = qw/3 9 12 1 2/;
>>$tot = sum ( @numbers );
>>print $tot;
>>
>>
>
>That's neat, and easy to read, besides :)
>
>Cheers,
>D
>
>
Agreed! It seems that the two best solutions (as I would call them)
bubbled up to the top immediately. I liked one because it was built-in,
and the other because the language was more set-oriented.
It got me thinking about the following excerpt from the List::Util man
page, and how the comment "nice to have in the perl core, but..." isn't
really a big problem with Perl (because it's so easily extensible,
unlike the proprietary languages I work with).
"List::Util contains a selection of subroutines that people have
expressed would be nice to have in the perl core, but the usage would
not really be high enough to warrant the use of a keyword, and the size
so small such that being individual extensions would be wasteful."
Under the following listing
http://cpan.uwinnipeg.ca/htdocs/Scalar-List-Utils/List/Util.html#suggested_additions
it took me a while to understand the precedence of the "for" and "&&",
as well as to remember that "foreach" is just a synonym for "for".
--
Mark Bole
http://www.bincomputing.com
925-287-0366
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/oakland/attachments/20050301/c5d0cb32/attachment.htm
More information about the Oakland
mailing list