March 2023 Archives

Introducing Exporter::Almighty

Consider a simple module like this:

  package MyApp::Util::Maths;
  
  use strict;
  use warnings;
  
  use constant PI    => 3.14159265358979;
  use constant EULER => 2.71828182845905;
  
  use base 'Exporter';
  
  our @EXPORT_OK = qw( PI EULER add );
  our %EXPORT_TAGS = (
    arithmetic => [ qw( add ) ],
    numbers    => [ qw( PI EULER ) ],
    all        => \@EXPORT_OK,
  );
  
  sub add {
    my ( $x, $y ) = @_;
    return $x + $y;
  }
  
  1;

About Toby Inkster

user-pic I'm tobyink on CPAN, IRC and PerlMonks.