.lib/perl5/Autofetch.pm

changeset 682
31d13f6d3a30
parent 681
a478dd55388a
child 690
d005acd0e883
equal deleted inserted replaced
681:a478dd55388a 682:31d13f6d3a30
13 catfile($ENV{HOME}, '.cache', 'lib', rel2abs($_[0]) =~ y|/ |-_|r); 13 catfile($ENV{HOME}, '.cache', 'lib', rel2abs($_[0]) =~ y|/ |-_|r);
14 } 14 }
15 15
16 sub modulefy { $_[0] =~ s/\.pm$//r =~ s|/|::|gr } 16 sub modulefy { $_[0] =~ s/\.pm$//r =~ s|/|::|gr }
17 17
18 my $path = cachepath($0); 18 sub import {
19 my $incpath = catfile($path, 'lib', 'perl5'); 19 return if our $INSTALLED++;
20 20
21 push @INC, $incpath, sub { 21 my $path = cachepath($0);
22 my (undef, $file) = @_; 22 my $incpath = catfile($path, 'lib', 'perl5');
23 23
24 fetch($path, modulefy($file)); 24 push @INC, $incpath, sub {
25 my (undef, $file) = @_;
25 26
26 return IO::File->new(catfile($incpath, $file)); 27 fetch($path, modulefy($file));
27 }; 28
29 return IO::File->new(catfile($incpath, $file));
30 };
31 }
28 32
29 1; 33 1;

mercurial