NAME

Sub::Import - import routines from most anything using Sub::Exporter

VERSION

version 1.002

SYNOPSIS

  use Sub::Import 'Some::Library' => (
    some_routine  => { -as => 'some_other_name' },
    other_routine => undef,
  );

Some more examples:

  # import a function with a custom name
  use Sub::Import 'Digest::MD5', md5_hex => {-as => 'md5sum'};

  # import multiple functions, each with its own name
  use Sub::Import 'MIME::Base64',
    encode_base64 => {-as => 'e64'},
    decode_base64 => {-as => 'd64'};

  # Import most functions with the "trig_" prefix, e.g. "trig_log",
  # "trig_sin", "trig_cos", etc.
  use Sub::Import 'Math::Trig', -all => {-prefix => 'trig_'};

  # Import PI-related functions with the "_the_great" suffix, e.g.
  # "pi_the_great", "pi2_the_great", etc.
  use Sub::Import 'Math::Trig', -pi  => {-suffix => '_the_great'};

DESCRIPTION

Sub::Import is the companion to Sub::Exporter. You can use Sub::Import to get Sub::Exporter-like import semantics, even if the library you're importing from used Exporter.pm.

The synopsis above should say it all. Where you would usually say:

  use Some::Library qw(foo bar baz);

...to get Exporter.pm semantics, you can now get Sub::Exporter semantics with:

  use Sub::Import 'Some::Library' => qw(foo bar baz);

PERL VERSION

This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.

Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.

WARNINGS AND LIMITATIONS

While you can rename imports, there is no way to customize them, because they are not being built by generators. At present, extra arguments for each import will be thrown away. In the future, they may become a fatal error.

Non-subroutine imports will not be importable via this mechanism.

The regex-like import features of Exporter.pm will be unavailable. (Will anyone miss them?)

AUTHOR

Ricardo Signes <cpan@semiotic.systems>

CONTRIBUTOR

Ricardo Signes <rjbs@semiotic.systems>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Ricardo Signes.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.