Actually, you can. For example, the following works just fine:

my $stdout= *STDOUT; print $stdout "Hello\n";
What you can't do is use a non-string as a hash key and expected it to stay a non-string.

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")

In reply to (tye)Re: Problems writing to filehandles contained in variables by tye
in thread Problems writing to filehandles contained in variables by blink

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.