http://qs321.pair.com?node_id=1095603


in reply to Re: Including modules and pragmas in caller's scope via use
in thread Including modules and pragmas in caller's scope via use

Indeed, I think it does. I had a chance to play around with it, and after a minor disagreement with autodie, I got it to do everything I needed.

For anyone reading this later on with the same question: the Import::Into docs make reference to autodie being difficult, but (to me, anyway) were a little vague on how to fix that. Almost all examples in the documentation use the following format:

my $target = scalar caller; $package->import::into($target, @arguments);

However, autodie doesn't work with the above approach, but they say "Some exporting modules, such as autodie or strictures, care about the filename they are being imported to.". But it took just a bit more effort than just using the alternate hashref syntax. With autodie, what worked the best for me was this:

my ($package, $filename, $line) = caller; autodie->import::into({ package => $package, filename => $filename, line => $line });

(Note both of these examples would go into your module's import sub, as usual with Import::Into.)

Replies are listed 'Best First'.
Re^3: Including modules and pragmas in caller's scope via use
by Haarg (Curate) on Aug 01, 2014 at 22:34 UTC
    The documentation could use some improvements for this. The better syntax would be:
    autodie->import::into(1);
    This imports to the package/file/line at caller level 1, which matches what you are doing manually.