in reply to Using a loop to process multiple files
You can't just use variables as part of other variables. And "T$iT.txt" searches for the variable $iT, and can't find it.
You can do this instead:
# always start your scripts with these two lines... use strict; use warnings; # and declare your variables foreach my $i (2 .. 4) { my $filename = 'T' . $i . 'T.txt'; open (my $file, $filename) or die "Can't open '$filename': $!"; my @a = <$file>; print @a; close $file; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using a loop to process multiple files
by Anonymous Monk on May 08, 2008 at 22:53 UTC |