mirror of
https://github.com/perlbot/perlbuut-pastebin
synced 2025-06-07 14:17:26 -04:00
30 lines
452 B
Perl
30 lines
452 B
Perl
package App::Config;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Exporter qw/import/;
|
|
use Data::Dumper;
|
|
use FindBin qw($Bin);
|
|
|
|
use TOML;
|
|
|
|
our @EXPORT=qw/$cfg/;
|
|
|
|
our $cfg = do {
|
|
my $toml = do {open(my $fh, "<", "$Bin/app.cfg"); local $/; <$fh>};
|
|
# With error checking
|
|
my ($data, $err) = from_toml($toml);
|
|
unless ($data) {
|
|
die "Error parsing toml: $err";
|
|
}
|
|
$data;
|
|
};
|
|
|
|
sub get_config {
|
|
my $key = shift;
|
|
|
|
return $cfg->{$key};
|
|
}
|
|
|
|
1;
|