At Filehandles vs. Packages: And the winner is... converter found an "interesting" feature of Perl. A short demonstration of it is:
perl -e 'sub new {die@_} main->new(); open main, "foo"'
which fails to find your new method in package main because main is being interpreted as a glob, not as a class name. The following snippet fixes that for some values of fix (as long as you don't later want to use IO::Handle of course).

Of course if in package IO::Handle you were to open a filehandle named CGI, then the workaround stops working...

package IO::Handle; sub new { *{shift(@_)}{NAME}->new(@_); }

In reply to Unconfuse filehandles and classes by tilly

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.