Ask the user for a list of sequence lengths, separated by whitespace (Example: 100 123 45 …etc.). The sequence lengths will be stored in a string called $input. a. Split the String $input and create an array. b. Use the foreach loop to get the sum of all sequence lengths. c. Print the average. this is what I have now: but I don't get the space at the print command.
use strict; use warnings; my $i = 0; my $input = ""; while ($i < 3) { chomp(my $num = <>); $input .= $num . "". $num; $i++; } print "Total input is $input\n"; my @nums = split(' ', $input); foreach (@nums) { my $sum += $_; } print my $sum / @nums . "\n"; exit;
In reply to Diagnose code by stamp1982
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |