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

Are you sure it didn't complain about $indexfiles? (Athanasius mentioned it but did not offer a suggestion.)

This: print $indexfiles, "\n";

Should be: print $indexfiles[$i], "\n";