This one confused me a lot too when I was first learning Perl!
You are probably thinking "yeah, sure - I *know* I passed an undefined variable to calcsum, but why is it causing a problem?! After all I passed "nothing" to calcsum!
My guess is that you think you are passing an undefined "array" when actually you are passing a list with a single value undef in it: (undef). Thus your foreach loop is equivalent to:
my @funcArray = (undef) #my @funcArray = @_; my $funcSum = 0; my $funcArr = 0; my $arrcount = 1; #my $arrcount = scalar(@_); foreach my $line ((undef)) { #foreach my $line (@funcArray) $funcSum += $line; }
Who'd ever thought - so much confusion from nothing?
Best, beth
In reply to Re: Use of uninitialized value in addition (+)
by ELISHEVA
in thread Use of uninitialized value in addition (+)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |