[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Finding the length of the longest string



The obvious (dull) way:

my $len = 0;
$len < length and $len = length
    for @data;

Subtler and somewhat faster:

my $len = "";
$len ^= $_ for @data;
$len = length $len;

Any better ideas?

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org