OK, I'm stumped. I'm trying to read from a file handle in a while loop. The reference to the file handle is in a hash which itself begins with a hash reference like this ...
my $cfg = {};
open (INFILE,"<testfile.txt") || die "Could not open file\n$!\n";
$$cfg{infile} = \*INFILE;
while(<$$cfg{infile}>){
print "$_\n";
}
__END__
GLOB(0x20eab18)
However, when I do it this way, it works as expected.
my $cfg = {};
open (INFILE,"<testfile.txt") || die "Could not open file\n$!\n";
$$cfg{infile} = \*INFILE;
my $infh = $$cfg{infile};
while(<$infh}>){
print "$_\n";
}
I figure that the angle operator is not dereferencing $$cfg{infile} as I want but I cannot come up with a combinations of parens, curly braces and arrows that will make this work. What am I missing?
Update: I knew I was missing the obvious. Thanks Roy. :o)
PJ
Unspoken but ever present -- use strict; use warnings; use diagnostics; (as needed)