develooper Front page | perl.beginners | Postings from April 2002

Re: Filehandles named with a variable

Thread Previous | Thread Next
From:
Jenda Krynicky
Date:
April 2, 2002 15:35
Subject:
Re: Filehandles named with a variable
Message ID:
3CAA5C44.7604.1197F3A7@localhost
From: Mr Hash <core@enodev.com>

> $1 is the resultant of a regex match. It don't need to be around very
> long, because I build a hash of open filehandles (key = filehandle
> string, value = file) at the time I open the file.
> 
> And no, I don't close 'em! exit() does just fine.

Something like:

use FileHandle;
foreach $file (@path_list) {
	my $FH = new FileHandle;
	open $FH, "< $file" or next;
	$files{$file} = $FH;
}

....

my $FH = $files{$name};
$next_line = <$FH>;
....

?

Jenda

=========== Jenda@Krynicky.cz == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
					--- me

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About