ostra has asked for the wisdom of the Perl Monks concerning the following question:
my program inputs values from a text file and stores them in an array called @nums. Is there an alternative code that can accomplish the same task? Thank you in advance, Ostra.
#!/perl/ -w @nums=(); #array of numbers $count=0; #count of numbers while(<>){ chomp($input=$_); if($input ne ''){ $nums[$count++]=$input; } else{last;} } @nums= sort {$a<=>$b} @nums; print "\nminimum number: $nums[0]"; print "\nmaximum number: $nums[$#count]";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: storage of numbers
by Laurent_R (Canon) on Oct 16, 2013 at 17:29 UTC | |
by BillKSmith (Monsignor) on Oct 17, 2013 at 02:53 UTC | |
by Laurent_R (Canon) on Oct 17, 2013 at 17:12 UTC | |
|
Re: storage of numbers
by davido (Cardinal) on Oct 16, 2013 at 17:42 UTC | |
by vsespb (Chaplain) on Oct 16, 2013 at 17:57 UTC | |
by ww (Archbishop) on Oct 16, 2013 at 19:56 UTC | |
by vsespb (Chaplain) on Oct 16, 2013 at 20:09 UTC | |
by vsespb (Chaplain) on Oct 16, 2013 at 20:07 UTC | |
by davido (Cardinal) on Oct 16, 2013 at 21:23 UTC | |
|
Re: storage of numbers
by GotToBTru (Prior) on Oct 16, 2013 at 20:20 UTC | |
|
Re: storage of numbers
by kcott (Archbishop) on Oct 17, 2013 at 07:16 UTC |