Hello TANYALYNN82,
You must have done more than just add $ to i, or you would be getting different warning messages. My guess is that you also removed this line:
my @indexfiles;
which would account for the error message you report. The point to understand is that $indexfiles and @indexfiles are two different variables, the first a scalar, the second an array. Changing one has no affect on the other. Now, when you say:
$indexfiles[$i] = ...
you are accessing the element at the $ith index of the array @indexfiles. If you haven’t declared it first (via my @indexfiles) then use strict will generate the error message you are seeing.
But even when you do declare @indexfiles, the code shown in the OP won’t do what you want, because the scalar variable $indexfiles, which is printed at the end of the foreach loop, is never changed, and so each print will result in a warning like this:
Use of uninitialized value $indexfiles in print at index.pl line...
I don’t know what you are trying to do here, so I can’t advise you further; but please read perlintro, especially Perl variable types.
Two additional points:
$parts[0] == 'ABC' attempts to compare whatever is in $parts[0] with the string 'ABC' using the numerical comparison operator ==. You should use eq instead.
While not strictly wrong in this instance, having two lexical variables named $build is certainly confusing. It would be better to choose a different name for the foreach variable.
Hope that helps,
|