The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

VERSION

Version 0.18

SYNOPSIS

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

If you find any issues in using the module, please don't hesitate to email me: pyh@gmx.fr

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("tags","cloud,virtual,kvm");

    print $db->get("provider"),"\n";
    $db->delete("tags");
    print  "tags exists? ", $db->exists("tags") ? "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/lsb-release");
    print "My OS is: ", $db->get("DISTRIB_ID");

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)