B::Hooks::OP::Check::StashChange allows one to run a callback whenever the current package changes during compilation. If a hook is installed, all subsequent calls to split appear to be removed. How is this possible?

Here's some code without a hook being installed:
INSTALL_HOOK=0 perl -MO=Deparse -MB::Hooks::OP::Check::StashChange -e +'BEGIN { my $id = B::Hooks::OP::Check::StashChange::register(sub {}) +if $ENV{INSTALL_HOOK}; } print split "x", "1x2"' use B::Hooks::OP::Check::StashChange; sub BEGIN { my $id = B::Hooks::OP::Check::StashChange::register(sub { } ) if $ENV{'INSTALL_HOOK'}; } print split(/x/, '1x2', 0); -e syntax OK
and here's the same code with the hook enabled:
INSTALL_HOOK=1 perl -MO=Deparse -MB::Hooks::OP::Check::StashChange -e +'BEGIN { my $id = B::Hooks::OP::Check::StashChange::register(sub {}) +if $ENV{INSTALL_HOOK}; } print split "x", "1x2"' use B::Hooks::OP::Check::StashChange; sub BEGIN { my $id = B::Hooks::OP::Check::StashChange::register(sub { } ) if $ENV{'INSTALL_HOOK'}; } print 'x', '1x2'; -e syntax OK

As you can see, "split" disappeared and it's arguments are simply being printed. The module code itself is pretty short but given my lack of experience with XS I can't pinpoint the issue. How can a builtin get disabled like this?


In reply to B::Hooks::OP::Check::StashChange causes split to disappear by kroach

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.