http://qs321.pair.com?node_id=689777


in reply to Re^3: Open in for loop/array structure
in thread Open in for loop/array structure

$filename = <$FN[$k]>; is still bad, though. Using glob without looping over its results makes no sense.
use strict; use warnings; my @FN = qw( a b ); for my $k (0..$#FN) { my $filename = <$FN[$k]>; print("$filename\n"); }
a Use of uninitialized value in concatenation (.) or string at 689777.pl + line 6.

If @FN contains glob patterns, then he wants

for (@FN) { while (defined(my $filename = glob($_))) { ... } }

If @FN contains file names (as it seems to), then he wants

for my $filename (@FN) { ... }

Although it looks like @FN isn't needed at all.

for (0..18, 20..28, 30..38) { my $filename = sprintf('out-02-%02d.txt', $_); ... }