That is not perl code. It won't even compile.
I assume you mean something more like this:
use strict;
use warnings;
my @array = qw/ foo bar baz blah /;
for(my $i = 0; $i < @array; $i++) {
print "$i $array[$i]\n";
}
Which is fine but this is better:
use strict;
use warnings;
my @array = qw/ foo bar baz blah /;
foreach my $filename (@array) {
print "$filename\n";
}
Please notice I added use strict; and use warnings these are a MUST when you are learning perl.
Also notice I did not use the actual open - I simplified to find the real root of the problem