initial import
[catagits/Catalyst-Plugin-ConfigLoader.git] / lib / Catalyst / Plugin / ConfigLoader / Perl.pm
CommitLineData
b2d85594 1package Catalyst::Plugin::ConfigLoader::Perl;\r
2\r
3use strict;\r
4use warnings;\r
5\r
6=head1 NAME\r
7\r
8Catalyst::Plugin::ConfigLoader::Perl - Load Perl config files\r
9\r
10=head1 DESCRIPTION\r
11\r
12Loads Perl files. Example:\r
13\r
14 {\r
15 name => 'TestApp',\r
16 Controller::Config => {\r
17 foo => 'bar'\r
18 }\r
19 }\r
20\r
21=head1 METHODS\r
22\r
23=head2 load( $file )\r
24\r
25Attempts to load C<$file> as a Perl file.\r
26\r
27=cut\r
28\r
29sub load {\r
30 my $class = shift;\r
31 my $confpath = shift;\r
32\r
33 my @files;\r
34 if( $confpath =~ /\.(.{2,4})$/ ) {\r
35 return unless $1 =~ /^p(er)?l$/;\r
36 @files = $confpath;\r
37 }\r
38 else {\r
39 @files = map { "$confpath.$_" } qw( pl perl );\r
40 }\r
41 \r
42 for my $file ( @files ) {\r
43 next unless -f $file;\r
44 return eval { require $file };\r
45 }\r
46}\r
47\r
48=head1 AUTHOR\r
49\r
50=over 4 \r
51\r
52=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
53\r
54=back\r
55\r
56=head1 COPYRIGHT AND LICENSE\r
57\r
58Copyright 2006 by Brian Cassidy\r
59\r
60This library is free software; you can redistribute it and/or modify\r
61it under the same terms as Perl itself. \r
62\r
63=head1 SEE ALSO\r
64\r
65=over 4 \r
66\r
67=item * L<Catalyst>\r
68\r
69=back\r
70\r
71=cut\r
72\r
731;