use strict; use List::Utils qw/max/; # add this line ... # rest of your code is unchanged # and then use the function in your final print statement print "The largest element is: " . max(@array) ."\n";