open's prototype makes just passing @_ not work. See tilly's answer for the way to do this.

Update: well, I was so sure the above wouldn't work that I didn't even try it...so I wasn't misled by the apparent success. Because Tanktalus's code doesn't use warnings, he/she is missing this:

Ambiguous call resolved as CORE::open(), qualify as such or use &
So in fact the sub never even gets called. To call a sub with the same name as a builtin, you need to specify & (or have actually overriden the builtin as described in perlsub). Modifying the code to say &open(my $fh.... gives the error I was cautioning about:
Can't use string ("3") as a symbol ref while "strict refs" in use
due to the scalar prototype on open's first argument. (@_ == 3).

In reply to Re^2: anonymous filehandle for overridden open sub by ysth
in thread anonymous filehandle for overridden open sub by blahblahblah

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.