NAME

DB::SimpleKV - Simple k/v interface to text configuration file

VERSION

Version 0.04

SYNOPSIS

This module is mainly used to manipulate a configuration file like Postfix's main.cf.

It creates the default db file "/tmp/simplekv.db" if you don't specify the file path.

use DB::SimpleKV;

my $db = DB::SimpleKV->new;
$db->set("hostname","h99.foo.com");
$db->set("provider","rackspace cloud");
$db->set("ip_addr","192.168.2.10");
$db->set("netmask","255.255.255.0");

print $db->get("provider"),"\n";
$db->delete("netmask");
print  "netmask exists? ", $db->exists("netmask") ? "yes" : "no", "\n";

$db->save;

Or you can specify the existing file for manipulation, one configuration per line, with '=' as delimiter.

use DB::SimpleKV;

my $db = DB::SimpleKV->new("/etc/postfix/main.cf");
print $db->get("relayhost"),"\n";
print  "relay exists? ", $db->exists("relayhost") ? "yes" : "no", "\n";

SUBROUTINES/METHODS

new

my $db = DB::SimpleKV->new(...);

If a file path was given, the delimiter in each line should be '='.

get

my $value = $db->get("key");

Get the value by key.

set

$db->set("key","value");

Set the key and value, either create them or update them.

delete

$db->delete("key");

Delete the key and value.

exists

if ($db->exists("key") ) {...}

To check if there is a key existing while the value can be undefined.

save

$db->save;

If db has been changed, should be written to disk finally.

AUTHOR

Ken Peng, <yhpeng at cpan.org>

BUGS

Please report any bugs or feature requests to bug-db-simplekv at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=DB-SimpleKV. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc DB::SimpleKV

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2022 by Ken Peng.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)