Config.pm 629 B

123456789101112131415161718192021222324252627282930
  1. package Trog::Config;
  2. use strict;
  3. use warnings;
  4. use Config::Simple;
  5. =head1 Trog::Config
  6. A thin wrapper around Config::Simple which reads the configuration from the appropriate place.
  7. =head2 Trog::Config::get() = Config::Simple
  8. Returns a configuration object that will be used by server.psgi, the data model and Routing modules.
  9. =cut
  10. our $home_cfg = "config/main.cfg";
  11. # Cache it in memory since we do that a lot elsewhere.
  12. my $cf;
  13. sub get {
  14. return $cf if $cf;
  15. $cf = Config::Simple->new($home_cfg) if -f $home_cfg;
  16. return $cf if $cf;
  17. $cf = Config::Simple->new('config/default.cfg');
  18. return $cf;
  19. }
  20. 1;