hershey964 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I have a question about File Handle references coming from a hash value. I have the following code:
my %fh; open (my $ref, ">", "somefile.txt"); $fh{'something'} = $ref; print $fh{'something'} "Hello World\n";
Doing this gives a weird compile error. I know if I add braces like this it will work: print {$fh{'something'}}
but
I'm allowed to do this: print $ref "Hello World\n";
My question is why do I need these braces? I'm storing the $ref in the value portion then referencing it with $fh{'something'}
Thank you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: printing to a file handle reference from a hash
by GrandFather (Saint) on Oct 18, 2013 at 22:04 UTC | |
|
Re: printing to a file handle reference from a hash
by marinersk (Priest) on Oct 19, 2013 at 05:39 UTC |