make inline-friendly

Thu, 15 Feb 2018 15:28:42 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Thu, 15 Feb 2018 15:28:42 -0500
changeset 682
31d13f6d3a30
parent 681
a478dd55388a
child 683
ea343e7d3abc

make inline-friendly

.lib/perl5/Autofetch.pm file | annotate | diff | comparison | revisions
--- a/.lib/perl5/Autofetch.pm
+++ b/.lib/perl5/Autofetch.pm
@@ -15,15 +15,19 @@ sub cachepath {
 
 sub modulefy { $_[0] =~ s/\.pm$//r =~ s|/|::|gr }
 
-my $path    = cachepath($0);
-my $incpath = catfile($path, 'lib', 'perl5');
+sub import {
+  return if our $INSTALLED++;
+
+  my $path    = cachepath($0);
+  my $incpath = catfile($path, 'lib', 'perl5');
 
-push @INC, $incpath, sub {
-  my (undef, $file) = @_;
+  push @INC, $incpath, sub {
+    my (undef, $file) = @_;
 
-  fetch($path, modulefy($file));
+    fetch($path, modulefy($file));
 
-  return IO::File->new(catfile($incpath, $file));
-};
+    return IO::File->new(catfile($incpath, $file));
+  };
+}
 
 1;

mercurial