Why do something C-style when you can speak simple Perlish?
my @sorted = sort {$b <=> $a} @numbers; my $highest = $sorted[0];
This sorts your array from highest to lowest and puts it in @sorted.
Update: changed "my $highest = $numbers[0];" to "my $highest = $sorted[0];" Many thanks to UnderMine for pointing this out.
John J Reiser
newrisedesigns.com
In reply to Re: (nrd) finding highest number
by newrisedesigns
in thread finding highest number
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |