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=936efab7540846b6aea7a6554b79e91ba1ea5e60;hb=49ae658349471834b403cb322f11f97258fcd0ca;hpb=8af0a7cf96c671f13244fec2e0f15a4c13f2737d diff --git a/lib/Config/Any/Perl.pm b/lib/Config/Any/Perl.pm index 936efab..daf27f6 100644 --- a/lib/Config/Any/Perl.pm +++ b/lib/Config/Any/Perl.pm @@ -3,6 +3,8 @@ package Config::Any::Perl; use strict; use warnings; +use base 'Config::Any::Base'; + my %cache; =head1 NAME @@ -46,22 +48,22 @@ sub load { my $file = shift; my $content; - unless ( $content = $cache{ $file } ) { - $content = require $file; - $cache{ $file } = $content; - } - - return $content; -} - -=head2 is_supported( ) + my $mtime = (stat($file))[9]; -Returns true. + if ( (not exists $cache{ $file }) || $cache{ $file }{ mtime } < $mtime ) { + my $exception; + { + local $@; + $content = do $file; + $exception = $@; + } + die $exception if $exception; -=cut + $cache{ $file }{ mtime } = $mtime; + $cache{ $file }{ content } = $content; + } -sub is_supported { - return 1; + return $cache{ $file }{ content }; } =head1 AUTHOR @@ -70,7 +72,7 @@ Brian Cassidy Ebricas@cpan.orgE =head1 COPYRIGHT AND LICENSE -Copyright 2007 by Brian Cassidy +Copyright 2006-2009 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.