[HRPM] Just a quick question...

Branson Matheson Branson.Matheson at FergInc.com
Thu Feb 8 16:28:02 CST 2001


> Does perl handle dynamic directory handles?  If so, how would one do
> it?  My instinct is to do this:  opendir(CURNT$i, "/etc"); but that
> also goes against concatination rules.  Since I am far from a
> workable piece and am too lazy to run a few tests, I thought I'd
> actually use this mailing list for once.  Anyone know how do
> acomplish something like this?

 Yes .. you have to use the FileHandle module .. such as:

 #! /usr/local/bin/perl

 use FileHandle;

 @dirs =  ( '/etc', '/usr/local', '/usr' ) ;

 for $dir ( @dirs ) {
 	$dh{$dir} = new FileHandle;
	opendir $dh{$dir}, $dir; 
}

@files = readdir($dh{'/etc'});

for $file ( @files ) { 
	print "$file\n"; 
}

 Hope this helps ;-)

  - branson

-------------------------------------------------------------------------------
Branson Matheson                       "If you are falling off of a mountain,
Manager, Risk and Information Security   You may as well try to fly." 
Ferguson Enterprises, Inc.               - Delenn, Minbari Ambassador 
           ( $statements = <BRANSON> ) !~ /Corporate Opinion/;



More information about the Norfolk-pm mailing list