public
Created

Pure Perl Configuration File

  • Download Gist
app.conf
1 2 3 4 5 6 7 8 9 10 11
{
database => 'donut',
user => 'homer',
password => 'simpson',
 
quote => {
give => 'me',
the => 'number',
for => 911,
},
}
app.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/env perl
 
use strict;
use warnings;
use Data::Dumper;
use Safe;
 
my $config = Safe->new->rdo( 'app.conf' );
die "Couldn't parse config file: $@" if $@;
die 'Invalid config file' if not defined $config or ref $config ne 'HASH';
 
print Dumper $config;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.