my $class = shift;\r
my $file = shift;\r
\r
+ # work around bug (?) in Config::General\r
+ return if $class->_test_perl($file);\r
+\r
require Config::General;\r
my $configfile = Config::General->new( $file );\r
my $config = { $configfile->getall };\r
return $config;\r
}\r
\r
+# this is a bit of a hack but necessary, because Config::General is *far* too lax\r
+# about what it will load -- specifically, it seems to be quite happy to load a Perl\r
+# config file (ie, a file which is valid Perl and creates a hashref) as if it were\r
+# an Apache-style configuration file, presumably due to laziness on the part of the\r
+# developer.\r
+\r
+sub _test_perl {\r
+ my ($class, $file) = @_;\r
+ my $is_perl_src;\r
+ eval { $is_perl_src = do "$file"; };\r
+ delete $INC{$file}; # so we don't screw stuff later on\r
+ return defined $is_perl_src;\r
+}\r
+\r
=head1 AUTHOR\r
\r
=over 4 \r
\r
=back\r
\r
+=head1 CONTRIBUTORS\r
+\r
+=over 4\r
+\r
+=item * Joel Bernstein C<< <rataxis@cpan.org> >>\r
+\r
+=back\r
+\r
=head1 COPYRIGHT AND LICENSE\r
\r
Copyright 2006 by Brian Cassidy\r
\r
+Portions Copyright 2006 Portugal Telecom\r
+\r
This library is free software; you can redistribute it and/or modify\r
it under the same terms as Perl itself. \r
\r
\r
=cut\r
\r
-1;
\ No newline at end of file
+1;\r
+\r