Each perl opcode is implemented by a pp_* routine, in this case pp_open() (in pp_sys.c).

In the latest sources, that eventually calls do_openn() in doio.c. That does a lot of preparatory work, and may hand off to one of various calls (eg, we may be opening a pipe, or duping an existing file handle), but in the simple case it hands off to PerlIO_openn() in perlio.c. What happens next depends on the defines with which your perl was compiled.

If you are using PERLIO, I think it then interrogates the layer stack for a layer that knows how to handle open, and then calls it. The layers consist of a table of function pointers, defined in perliol.h (and documented in pod/perliol.pod). I'm not sure where these tables are initialised.

I think in your case you are talking about the IPerlSys abstraction, mostly defined in iperlsys.h where I see PerlSIO_fopen() being defined in terms of the fopen() implementation you mention; that appears to be used only in PerlIOStdio_open() in perlio.c. However the 'IPerlStdIO' structure definition looks very similar to a PerlIO vector table, so I may be missing a point where it is used as one and its entry for pOpen being called directly.

I'm afraid I don't know enough about this area to give chapter and verse, but I hope I've given you enough information to help track down what you're actually looking for.

Hugo


In reply to Re: Anatomy of 'perl', the interpreter by hv
in thread Anatomy of 'perl', the interpreter by John M. Dlugosz

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.