Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: extracting the largest values

by murugu (Curate)
on Nov 22, 2005 at 13:35 UTC ( #510772=note: print w/ replies, xml ) Need Help??


in reply to extracting the largest values

Hi Angharad,

I think this do what you need,

use strict; use warnings; my @input = <DATA>; chomp @input; my ($max, $s_max) = sort { $b<=>$a} @input; print $max,$",$s_max,$/; __DATA__ 0.2430 0.0830 0.1320 0.0920 0.0180 0.0880 0.3440

Regards,
Murugesan Kandasamy
use perl for(;;);


Comment on Re: extracting the largest values
Download Code
Replies are listed 'Best First'.
Re^2: extracting the largest values
by Perl Mouse (Chaplain) on Nov 22, 2005 at 14:28 UTC
    That could be rather inefficient if there are a lot of numbers.
    Perl --((8:>*

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (16)
As of 2015-07-31 11:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls