in reply to Re: Passing on "use"s
in thread Passing on "use"s

Looks nice! So, uh...

use Import::Into; sub import{ feature->import::into(scalar caller,'say'); }

That doesn't seem to do anything either. What am I missing?

Replies are listed 'Best First'.
Re^3: Passing on "use"s
by 1nickt (Canon) on Oct 29, 2023 at 16:47 UTC

    GenericModule.pm:

    package GenericModule; use Import::Into; feature->import::into(1, 'say'); 1;

    111155275.pl:

    use GenericModule; say 'hello,world';

    Script run:

    $ perl -I. 111155275.pl hello,world

    Hope this helps!


    The way forward always starts with a minimal test.

      Huh! So I don't need sub import, or caller? Just a 1? Well I have no idea what's going on, but it does work, so that's all fine by me. Thanks!

        You're right, a more correct, more scalable version would use sub import { ... }

        package GenericModule; use Import::Into; sub import { feature ->import::into(1, 'say'); utf8 ->import::into(1); List::Util->import::into(1, 'shuffle'); } 1;


        The way forward always starts with a minimal test.

        It's the caller level:
        $target can be an package name to export to, an integer for the caller level to export to, or a hashref with the following options...


        The way forward always starts with a minimal test.