Wiggins d'Anconia <[EMAIL PROTECTED]> wrote:
> Though it seems a bit odd that you want to recursively read a
> filehandle.
It certainly would be a cool way to handle include
directives when parsing config files, i.e.
my $conf = "/etc/apache/httpd.conf"
open( my $fh, $conf ) or die "Can't open '$conf': $!";
my @todo = ( $fh );
while( @todo ){
$fh = pop @todo;
while( my $line = <$fh> ){
# parse config
# ...
if( $line =~ m/^\s+include\s+(\S+)/i ){
push @todo, $fh;
my $fname = qualify( dequote( $1 ) );
open( $fh, $fname ) or die "Can't open '$fname': $!";
}
}
}
I'll have to try that some time ;-)
Cheers,
Thomas
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>