pileofrogs has asked for the wisdom of the Perl Monks concerning the following question:
If I stick a file handle into a hash, is there a way to read from the filehandle ala <$handle> without copying the file handle to a scalar first? Here's some code...
#! /usr/bin/perl -w -T use strict; # assuming 'foo' exists open( my $handle, '<', 'foo' ); my %hash = ( handle => $handle); # prints out GLOB(0x9d2cc28) while( <$hash{handle}> ) { print; } my %worse_yet = ( hash => \%hash ); # won't compile while( <$worse_yet{hash}->{handle}> ) { print; } # I tried *{$worse_yet{hash}->{handle}} and it didn't work either
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using File Handle in hash
by ikegami (Patriarch) on Jun 30, 2009 at 20:49 UTC | |
|
Re: Using File Handle in hash
by Fletch (Bishop) on Jun 30, 2009 at 20:17 UTC |