7 use Text::Tradition::Directory;
9 binmode STDOUT, ':utf8';
10 binmode STDERR, ':utf8';
11 eval { no warnings; binmode $DB::OUT, ':utf8'; $DB::deep = 1000 };
15 DBHOST => '127.0.0.1',
17 DBNAME => 'idpresult',
23 if( -f "/etc/graphcalc.conf" ) {
24 # Read the variables in from here.
25 open( GCCONF, "/etc/graphcalc.conf" )
26 or die "Could not open configuration file /etc/graphcalc.conf";
30 my( $name, $val ) = split( /\s*\=\s*/, $_ );
31 if( exists $VARS{$name} ) {
37 unless( $VARS{DSN} ) {
38 $VARS{DSN} = sprintf( "dbi:%s:dbname=%s;host=%s;port=%s",
39 $VARS{DBTYPE}, $VARS{DBNAME}, $VARS{DBHOST}, $VARS{DBPORT} );
42 my $dirargs = { create => 1 };
43 $dirargs->{user} = $VARS{DBUSER} if $VARS{DBUSER};
44 $dirargs->{password} = $VARS{DBPASS} if $VARS{DBPASS};
45 my $dir = Text::Tradition::Directory->new(
46 'dsn' => $VARS{DSN}, 'extra_args' => $dirargs );
47 my $scope = $dir->new_scope();
49 say "Initialized database at " . $VARS{DSN};