in reply to Re^2: Read/Create files
in thread Read/Create files

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:

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,