Hello all,
So I'm writing another ultra simple, and pretty pointless, learning program. Here is the start of it
#!/usr/bin/perl use strict; use warnings; print "\nMean Average Program\n\nenter values, when done enter 'done'\ +n\n"; my $total = 0; my @value; my $control = 1; while ($control != 0){ print "Enter a value('done' if finished): "; chomp($value[$total] = <>); if ($value[$total] eq 'done' || $value[$total] eq 'Done' || $value[$ +total] eq 'DONE'){ $control = 0; } $total++; }; pop(@value); $total--; my $mean = 0; for my $valNum (0 .. $total){ $mean += $value[$valNum]; } $mean = $mean / $total; print "\nThe mean of your values is $mean\n";
The code runs and does the calculations right, but I get an error message in the middle of running in the vien of the title.
the error message points me to this line: $mean += $value[$valNum];
I've tried adding a line before the loop initializing valNum with 0 and got rid of the my in the for loop, and it still said the same thing. I know it's prob something simple, but I'm not seein the prob, need some help please.
In reply to Use of uninitialized value in addition by Solarplight
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |