X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=lib%2FConfig%2FAny%2FPerl.pm;h=daf27f6df48e4dfc9264ba3e11c3f8bce5ded4d9;hp=fee9e4d86a37036fa1bb7fc77a9408b1c95c606f;hb=49ae658349471834b403cb322f11f97258fcd0ca;hpb=c793253e5f2ad3ca9d60e96e07a5d87fa344ec31 diff --git a/lib/Config/Any/Perl.pm b/lib/Config/Any/Perl.pm index fee9e4d..daf27f6 100644 --- a/lib/Config/Any/Perl.pm +++ b/lib/Config/Any/Perl.pm @@ -48,12 +48,22 @@ sub load { my $file = shift; my $content; - unless ( $content = $cache{ $file } ) { - $content = require $file; - $cache{ $file } = $content; + my $mtime = (stat($file))[9]; + + if ( (not exists $cache{ $file }) || $cache{ $file }{ mtime } < $mtime ) { + my $exception; + { + local $@; + $content = do $file; + $exception = $@; + } + die $exception if $exception; + + $cache{ $file }{ mtime } = $mtime; + $cache{ $file }{ content } = $content; } - return $content; + return $cache{ $file }{ content }; } =head1 AUTHOR