In trying to get somewhere with [id://???] I wrote a quick XS library to gain access to some perl internal variables. My initial thought was to create an accessor for each variable I was interested in and just write a normal perl sub to format and print them. No such luck. My XSUB accessors returned globs instead of integers. I think this is really basic stuff but it still eluded me.

All I did was a basic `h2xs -n Devel::DebugScope`, edit the created .xs file to add my functions and run it. Eventually I just punted and did the dump right from the C code. I've included that bit as well.

MODULE = Devel::DebugScope PACKAGE = Devel::DebugScope + PREFIX = ds_ I32 ds_scopestack_ix() CODE: RETVAL = PL_scopestack_ix; int ds_savestack_ix() CODE: RETVAL = PL_savestack_ix; void dump_scope() CODE: printf("scopestack_ix: %d\n", PL_scopestack_ix); printf("savestack_ix: %d\n", PL_savestack_ix); __END__ print savestack_ix() returns "*main::savestack_ix" This is the part that eludes me. It should just be an integer and wher +e the glob comes from... *shrug*

Fun Fun Fun in the Fluffy Chair


In reply to XS code returns GLOB instead of IV by diotalevi

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.