NAME

Exporter::Handy::Util - Routines useful when exporting symbols thru Exporter and friends

VERSION

version 1.000000

SYNOPSIS

Define a module with exports

package My::Utils;
use Exporter::Handy -exporter_setup => 1;

export(qw( foo $x @STUFF -strict_and_warnings ), ':baz' => ['foo'] );

sub foo { ... }

sub strict_and_warnings {
  strict->import;
  warnings->import;
}

Create a new module which exports all that, and more

package My::MoreUtils;
use My::Utils -exporter_setup => 1;
sub util_fn3 : Export(:baz) { ... }

Use the module

use My::MoreUtils qw( -strict_and_warnings :baz @STUFF );
# Use the exported things
push @STUFF, foo(), util_fn3();

DESCRIPTION

This module is currently EXPERIMENTAL. You are advised to restrain from using it.

You have been warned.

FUNCTIONS

xtags

Build one or more export tags suitable for Exporter and friends, such as: Exporter::Extensible, Exporter::Handy, Exporter::Tiny, Exporter::Shiny, Exporter::Almighty, ...

use Exporter::Handy::Util qw(xtags);
use Exporter::Handy -exporter_setup => 1

export(
    foo
    baz
    xtags( ':' => {
      bar => [qw( $bozo @baza boom )]
    }),
);

expand_xtags

Expand tags in a manner compatible with Exporter and friends, such as: Exporter::Extensible, Exporter::Handy, Exporter::Tiny, Exporter::Shiny, Exporter::Almighty, ...

use Exporter::Handy::Util qw(expand_xtags);

our @EXPORT = qw( slurp uniq );
our %EXPORT_TAGS = (
  file    => [qw( slurp spew )],
  io      => [qw( :file open4 ) ],
  list    => [qw( uniq zip )],
  default => \@EXPORT,
);
say expand_xtags(\%EXPORT_TAGS, qw(file) );                  # prints: file
say expand_xtags(\%EXPORT_TAGS, qw(:file open4) );           # prints: slurp, spew, open4

say expand_xtags(\%EXPORT_TAGS, @EXPORT_TAGS{qw(io list)} ); # prints: slurp, spew, open4, uniq, zip

our @EXPORT_OK = expand_xtags(\%EXPORT_TAGS, values %EXPORT_TAGS);
@EXPORT_OK     = expand_xtags(\%EXPORT_TAGS, { keys => \'*' });

AUTHORS

Tabulo[n] <dev@tabulo.net>

LEGAL

This software is copyright (c) 2023 by Tabulo[n].

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