The $max variable should be initialised by shift()ing a value from @array. A small change would be required to the regex to allow negative numbers too. So we have
#!/usr/bin/perl -w
use strict;
my @array=(-3,-4,-2);
my $max=shift @array ;
foreach (@array) {
if (/^-?\d+$/) {
$max=$_ if ($_>$max)
}
}
print $max;