--- 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;