in reply to finding highest number
hope this helps#!/usr/bin/perl -w use strict; use List::Util; #for the max function my @numbers = qw( 10 4 7 2 5 8 1 3 11); my $highest=$numbers[0]; # Initialise this for case of all negatives for (my $i = 1; $i < @numbers; $i++) { if ($numbers[$i] > $highest) { #compare to the previous hig +hest $highest = $numbers[$i]; } } print "\$highest is $highest\n"; #now use List::Util::max print "Max is ", List::Util::max(@numbers),"\n";
|
---|