I would suggest a different method... In Perl if you have some @x and you want to find the maximum value, the easy way is to just sort @x and take the last element with a slice...like below. The -1 index means "last one". Note that this will work for max,min even if there is only one thing in @x. Now granted sort is slower than some one pass "is this the biggest algorithm" but it is very simple to use and is faster than you might think. Use the power of the language and optimize later if you need to.
#!/usr/bin/perl -w
use strict;
my @x =(56, 78, 3, -1, 15);
my ($max, $min) = (sort {$a <=> $b} @x)[-1,0];
print "max = $max, min =$min\n"; #prints: max = 78, min =-1
updated: numeric sort
the default is alphabetic comparison and that would give -1 15 3 56 7 78 which of course isn't right! So specifying $a <=> $b specifies the "spaceship" operator, a numeric comparison rather than the default of $a cmp $b which is an alpha comparison.
update again: see ikegami's post.