For the sake of completeness, yet another approach would be to
directly import Exporter's import method into the
namespace of your module. In that case it doesn't need to be looked
up via inheritance, so you don't need to setup @ISA or
use base ...
In other words, from the following 3 options, you can choose
whichever you like best:
package One;
use strict;
use warnings;
# --- option 1 - inheritance via @ISA
# require Exporter;
# our @ISA = qw(Exporter);
# ---
# --- option 2 - inheritance via use base ...
# use base "Exporter";
# ---
# --- option 3 - directly import Exporter's import()
use Exporter "import";
# ---
# ( @EXPORT or @EXPORT_OK always needed )
our @EXPORT = qw(method1);
sub method1 {
print "method1 greets hello";
}
1;
(Also, note that I changed the package name to "One" (capitalized).
AFAIK, lowercase module names are - by convention - reserved for
pragmatic modules like use strict;, use integer;, etc.)
BTW, a slight peculiarity with use strict; use warnings;
in this particular case is that it does not (and cannot) warn you
about potential problems due to not loading Exporter yourself
(because, as ferreira pointed out, Exporter already is being
loaded as a side effect of using strictures). For this reason,
it could be argued that options 2 or 3 are the ones to prefer, as they
do not share this potential pitfall...