in reply to Re^3: XS: use module into package
in thread XS: use module into package

But the code the eval executes is being parsed into a sequence of API calls that finally end up changing the caller package by using a module into it. I'm looking for these API functions.

Except that maybe these are not "API" calls, but really internal stuff not meant for the general public.

Replies are listed 'Best First'.
Re^5: XS: use module into package
by ikegami (Patriarch) on Jun 13, 2011 at 19:13 UTC

    You can't go and change the package the parent Perl code was compiled into. You have to create new code and have it executed by Perl. Perl code gets compiled into ops, not API calls. package itself doesn't even result in an op because it's compiler directive. It changes the package Perl code gets compiled into.

      Well, I was thinking of doing this during compilation, ie in a BEGIN code block or in my import sub. For instance:
      package Mycaller; use MyModule; ...

      That way MyModule would be called during compilation, even pefore the rest of the calling module has even been parsed.

      My intention is to make the caller package use something else... without an eval.

        What about eval do you want to avoid?

        My intention is to make the caller package use something else... without an eval

        Again, package is a compiler directive. That means you need to invoke the compiler (eval).