.lib/perl5/Autofetch.pm

changeset 682
31d13f6d3a30
parent 681
a478dd55388a
child 690
d005acd0e883
--- 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