Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: The longest word ....

by pg (Canon)
on Nov 12, 2002 at 04:30 UTC ( [id://212194]=note: print w/replies, xml ) Need Help??


in reply to Re: The longest word ....
in thread The longest word ....

There could be more than one longest words having the same length, you probably want all of them:
use strict; my @words = ("one", "two", "123456789012345", "three", "four", "sumofa +llnumbers", "five", "six", "seven", "eight"); my @sorted_words = sort {length($b) <=> length($a)} @words;

my @longest_words = grep (/.{$#sorted_words}/, @words);
print join(",", @longest_words);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://212194]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found