Question: what is error in this code? 
could any give code for peak finding in an 1-d array in perl code?
I tried but i could complete if some one help me out.`

```
@a=(5.7,5.3,8.2,16.5,34.2,58.8,5.9,8,5,27.8);
@a=\$ptr;
$i;
$f=1;
$l=10;
$num=@a;
print"\nthe num of elements in array:$num";
$s=0;
$s=$s+$_ for @a;
print"\nthe sum of all elements in array:$s";
$mean=$s/$num;
print"\n the mean is :$mean";
$mid=($f+$l)/2;
print"\nthe mid point:$mid";
print"\nthe middle element :$a[5]";
unless($a[$i]==$a[5])
{if($a[$i]>$a[5])
for ($i=$a[5];$a[$i]<$a[5];$i--);
{
$ptr=$a[$i-1];
$ptr->$max;
print"$max";
}
}`

```

Answer: 
The cleanest way to find the max is to use the core [List::Util](http://perldoc.perl.org/List/Util.html) module.

```
use List::Util qw(max);

my $max = max @arr;

```
Perl has a built in `sort` function that should help in this situation.

```
a@ = sort {$b <=> $a} @a;
print "$a[0]";

```