added a simple cache to the perl parser so it can load the same file twice (RT #28812)
[p5sagit/Config-Any.git] / lib / Config / Any / Perl.pm
index 6c20ced..1dd1499 100644 (file)
@@ -3,6 +3,8 @@ package Config::Any::Perl;
 use strict;
 use warnings;
 
+my %cache;
+
 =head1 NAME
 
 Config::Any::Perl - Load Perl config files
@@ -42,7 +44,14 @@ Attempts to load C<$file> as a Perl file.
 sub load {
     my $class = shift;
     my $file  = shift;
-    return eval { require $file };
+    my $content;
+
+    unless( $content = $cache{ $file } ) {
+        $content = eval { require $file };
+        $cache{ $file } = $content;
+    }
+
+    return $content;
 }
 
 =head1 AUTHOR