in reply to Re: Breaking XS for testing? (@INC code ref)
in thread Breaking XS for testing?

The problem with that is that I still want the pure-Perl part of Scalar::Util to work. My test file was just a idealized case to show that it can be done.

In the real case, I want to load parts of Scalar::Util that have Perl fall-backs, try to load weaken, detect if it fails, and then have a sensible response (in this case, issuing a warning and continuing). So I need to interrupt XS loading only, without affecting @INC. Otherwise, I'd probably have gone tried that.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^3: Breaking XS for testing? (@INC code ref)
by tye (Sage) on Mar 06, 2006 at 23:06 UTC

    I was assuming a sane "fallback if no XS version available" scheme such as I've seen many times, where something like Scalar::Util_XS is a separate module that is only optionally installed. But Scalar::Util doesn't use this level of sanity and instead implements a lot of special installation machinery in order to allow it to install just parts of itself, so you have to learn its own flavor of magic in order to deal with it.

    It looks like overriding DynaLoader::bootstrap() would suffice:

    require Dynaloader; my $orig= \&DynaLoader::bootstrap; *DynaLoader::bootstrap= sub { ... };

    - tye