in reply to open and closing filehandles within a loop
You've got most of the elements there, but you've commented out the loop. Its problem appears to be overuse of the $host variable, as well as some typos. Here's my take,
#!/usr/bin/perl -w use strict; open HOSTLIST, "< hosts" or die $!; my @hosts = <HOSTLIST>; chomp @hosts; close HOSTLIST or die $!; for my $host (@hosts) { open INQ_ET, "< $host" or warn $! and next; for (<INQ_ET>) { # do stuff } close INQ_ET; }
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: open and closing filehandles within a loop
by Anonymous Monk on Oct 28, 2003 at 18:45 UTC |