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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.