Let's use Import::Base

Sun, 18 Feb 2018 16:11:32 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 18 Feb 2018 16:11:32 -0500
changeset 691
5e08af1add1e
parent 690
d005acd0e883
child 692
4573c0ed4d0d

Let's use Import::Base

.lib/perl5/ReplyStartup.pm file | annotate | diff | comparison | revisions
bin/setup-cpan-faves file | annotate | diff | comparison | revisions
--- a/.lib/perl5/ReplyStartup.pm
+++ b/.lib/perl5/ReplyStartup.pm
@@ -1,22 +1,29 @@
 package ReplyStartup;
+use warnings;
+use strict;
+use parent 'Import::Base';
+
+our @IMPORT_MODULES = (
+  'strict',
+  'warnings',
+  'feature' => [':5.14'],
+  'experimentals',
+  'Path::Tiny',
+);
 
 sub import {
-  my $code = eval(<<END_PERL) or die $@;
-    package main;
-    sub {
-      warnings->import;
-      strict->import;
-      require feature; feature->import(':5.14');
-      require experimentals; experimentals->import;
+  my $caller = caller(0);
 
-      use Path::Tiny;
-
+  # Run anything in .replyrc.local.pl in the context of main, at compile time.
+  eval(<<END_PERL)->();
+    package $caller; sub {
       -e \$_ && do(\$_) for glob('~/.replyrc.local.pl');
       die \$@ if \$@;
     }
 END_PERL
 
-  $code->();
+  our @ISA;
+  goto($ISA[0]->can('import'));
 }
 
 1;
--- a/bin/setup-cpan-faves
+++ b/bin/setup-cpan-faves
@@ -10,6 +10,7 @@ Pod::Cpandoc
 
 Perl::Tidy
 
+Import::Base
 experimentals
 
 Reply

mercurial