On Jan 9, Yacketta, Ronald said:
>looking for a simple example of putting a set of filenames into an array
>and then opening each of them for parsing.
>
>@files = ( "file1", "file2", "file3" );
>
>foreach $file (@files) {
> open FN, "< $file";
> do something here
> close
>}
This is fine. You could even have variables in the array.
@files = ($this, $that, "known.txt");
If you really need to treat each file separately, your code above is fine,
but you can take advantage of a Perl trick if you can allow the files to
be treated as one big file:
{
local @ARGV = ($this, $that, "foo", "bar");
while (<>) {
# $_ is a line from a file
}
}
That will open $this, and when it's empty, it'll open $that, and then
"foo", and then "bar".
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]