Adding external config file
This commit is contained in:
parent
f2f6e9782c
commit
75e2acfec9
2 changed files with 11 additions and 1 deletions
6
myapp.conf.example
Normal file
6
myapp.conf.example
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
foo => 'bar',
|
||||
banana => 'monkey',
|
||||
# Database connection details
|
||||
dsn => "dbi:SQLite:dbname=foodloop.db",
|
||||
};
|
|
@ -5,7 +5,11 @@ use Data::UUID;
|
|||
|
||||
# connect to database
|
||||
use DBI;
|
||||
my $dbh = DBI->connect("dbi:SQLite:dbname=foodloop.db") or die "Could not connect";
|
||||
my $config = plugin Config => {file => 'myapp.conf'};
|
||||
|
||||
use Devel::Dwarn; Dwarn $config;
|
||||
|
||||
my $dbh = DBI->connect($config->{dsn}) or die "Could not connect";
|
||||
|
||||
# shortcut for use in template
|
||||
helper db => sub { $dbh };
|
||||
|
|
Reference in a new issue