oh, add the cache path too

Wed, 14 Feb 2018 12:25:53 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Wed, 14 Feb 2018 12:25:53 -0500
changeset 678
4c569c2420f1
parent 677
15d353917450
child 679
2c32255d5c84

oh, add the cache path too

.lib/perl5/Autofetch.pm file | annotate | diff | comparison | revisions
--- a/.lib/perl5/Autofetch.pm
+++ b/.lib/perl5/Autofetch.pm
@@ -2,28 +2,24 @@ package Autofetch;
 
 use strict;
 use warnings;
-use 5.010;
 
 sub fetch {
   my ($path, $module) = @_;
   system 'cpanm', -nq, -l => $path, $module;
 }
 
-sub cachepath {
-  $ENV{HOME} . '/.cache/lib/' . ($_[0] =~ y|/ |-_|r);
-}
+sub cachepath { "$ENV{HOME}/.cache/lib/" . ($_[0] =~ y|/ |-_|r) }
+
+sub modulefy { $_[0] =~ s/\.pm$//r =~ s|/|::|gr }
 
-sub modulefy {
-  $_[0] =~ s/\.pm$//r =~ s|/|::|gr;
-}
+my $path = cachepath($0);
 
-push @INC, sub {
+push @INC, "$path/lib/perl5", sub {
   my (undef, $file) = @_;
-  state $path = cachepath($0);
 
   fetch($path, modulefy($file));
 
   return IO::File->new($path . '/lib/perl5/' . $file);
 };
-  
+
 1;

mercurial