If you only need the min and the max, then you don't need to store your numbers and an array and then sort the array: just maintain a $min and $max variables as you read the file. Possibly something like this:
EDIT: fixed a typo on the $max variable name.my ($min, $max) = (0, 0); while(<>){ chomp($input=$_); if($input ne ''){ $min = $input if $input < $min; $max = $input if $input > $max; } else{last;} } print "Min and Max are : $min $max \n";
In reply to Re: storage of numbers
by Laurent_R
in thread storage of numbers
by ostra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |