30 lines
432 B
Perl
30 lines
432 B
Perl
package MarkovBot::Config;
|
|
use base qw(Exporter);
|
|
use 5.010;
|
|
use strict;
|
|
use warnings;
|
|
|
|
our @EXPORT = qw(config);
|
|
|
|
use FindBin qw($Bin);
|
|
use YAML::Tiny;
|
|
|
|
sub config( $ ) {
|
|
# config(var)
|
|
# returns config value
|
|
|
|
my $file = "$Bin/config.yml";
|
|
for (0..$#ARGV) {
|
|
if ($ARGV[$_] eq "-f") {
|
|
$file = $ARGV[$_+1];
|
|
}
|
|
}
|
|
|
|
my $var = shift;
|
|
|
|
my $yaml = YAML::Tiny->read( $file );
|
|
return $yaml->[0]->{$var};
|
|
}
|
|
|
|
1;
|