- 4,229
- 61
How do you return the largest numeric value in an array, in Perl?
The discussion revolves around finding the largest numeric value in an array using Perl. Participants explore various methods and approaches to achieve this, including both simple comparisons and iterative techniques.
Participants present multiple approaches and methods without reaching a consensus on a single best solution. There is acknowledgment of different techniques suitable for varying array sizes and contexts.
Some methods rely on specific assumptions about the input data, such as the presence of numeric values, and there are unresolved details regarding Perl syntax and logical comparisons.
Individuals interested in Perl programming, particularly those looking to manipulate arrays and find maximum values, may find this discussion beneficial.
I don't think perl has a maximum function so you have to do something likeMonique said:How do you return the largest numeric value in an array, in Perl?
my $tmp='';
map {$tmp=$_ if ($_>$tmp and $_=~/^-?\d*.?\d*$/s and $_=~ /\d/} @array
die("The array doesn't contain any numbers ") unless ($tmp=~ /\d/);
return $tmp;
if ($frame1>$frame2&&$frame3){
$ORF=$frame1;
} elsif ($frame2>$frame3){
$ORF=$frame2;
} else {
$ORF=$frame3;
}
$frame1>$frame2&&$frame3
