in reply to •Re: Problems writing to filehandles contained in variables
in thread Problems writing to filehandles contained in variables
Actually, you can. For example, the following works just fine:
What you can't do is use a non-string as a hash key and expected it to stay a non-string.my $stdout= *STDOUT; print $stdout "Hello\n";
Even if the above code were switched to use \*INCNT (which I would recommend be done if for no other reason than so that it is more obvious that these are special things that aren't just strings) all that would happen would be that the error message would change to: Can't use string ("GLOB(0xbadd0g)") as a symbol ref while "strict refs" in use To solve the problem you could use Tie::RefHash or you could make the key just "INCNT" and have a value in the hash that is the handle: $anchors{INCNT}{handle}= \*INCNT; (or an IO::Handle if you prefer).
- tye (but my friends call me "Tye")
|
|---|