print "Please enter a number: \n"; my ($limit)= <STDIN>; chomp $limit; my $sum = 1; my @array = (); for (my $i=1; $i<=$limit; $i+=2) { $sum += 2 push(@array,'1') } my $average = $sum/scalar(@array); print "$average\n";
after the push (which means you need the aforementioned semicolon) to see what is going on:print "i: $i, sum: $sum, array: @array, scalar: ", scalar(@array), "\n +";
In reply to Re: New Perl user - help with my homework
by soonix
in thread New Perl user - help with my homework
by Eardrum
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |