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

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.

Replies are listed 'Best First'.
Re^4: Passing on "use"s
by Chuma (Scribe) on Oct 29, 2023 at 17:17 UTC

    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.