Thank you. I was thinking about taking this road, using eval to switch package. I can't goto &$sub to erase the current stack frame, because I need to do the track housekeeping after the open, and record the (possible mutated) $_[0]. OTOH... thinking about it, I could switch package in that eval'ed sub again and do the housekeeping there. To that end, the %fh fieldhash must be a package var. Oh well.

Currently, I am inspecting $_[0] with Devel::Caller etc. to find out whether the filehandle variable is lexical, package global, typeglob, bareword etc and trying to do the right thing. Anyways the overridden open would show up in the stack trace of Carp::cluck, so another stack frame wouldn't matter I guess. But with Sub::Name I could make that sub into the calling package. Maybe that's the best way to do it. It is definitely the cheapest in effort :-) update: and maybe the most robust also...

Thanks again, salva!

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

In reply to Re^6: Track open file handles by shmem
in thread Track open file handles by shmem

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.