NAME

Simplestore - simple storage format for hash refs

SYNOPSIS

use Simplestore;

# somefile contains:
#   word purrl
#   foo eggs
my $hash = Simplestore::load('somefile');
say $hash->{word}; # purrl

$hash->{foo} = 'bar';
$hash->{sentence} = "Mind the\nnewnile.;
Simplestore::save('somefile', $hash);

# somefile contains:
#   word purrl
#   foo bar
#   sentence Mind the
#   sentence newline.

DESCRIPTION

Simplestore is a perl library to store hashes in a very simple, easy-to-parse file format.

Note that it can only store simple hashes with string/digit values and word keys (the key must match \w+, like a perl variable name for example). References or any other complex stuff are not supported.

FUNCTIONS

Note: The function names are quite generic, so by default they are not exported. Use use Simplestore qw/load save/ if you want to use them directly.

Simplestore::load(storefile[, hashref])

Load the hash saved in storefile. Returns a hash ref containing the hash saved in storefile.

If hashref is specified, storefile will not be loaded into an empty hash, but into hashref. However, keys in storefile overwrite those in hashref.

Simplestore::save(storefile, hashref)

save hashref in storefile. Returns nothing.

STORAGE FORMAT

The store file contains key-value-pairs, each of them separated by a newline, the key and value are separated by a single tab. If a value contains newlines, they will be printed, but the next line(s) will be prefixed by the key. For a little example, see SYNOPSIS.

MOTIVATION

Simplestore aims to provide a common, simple format to store data. The format is extremely easy to parse in almost all languages, even C or Shell, thus Simplestore should offer a good way to exchange non-complex data between apps of all kinds.

COPYRIGHT

Copyright (C) 2009 by Daniel Friesel. Licensed under the terms of the WTFPL <http://sam.zoy.org/wtfpl>.