NAME
Data::Sofu - Perl extension for Sofu data
SYNOPSIS
require Data::Sofu;
my $sofu=new Sofu;
%hash=$sofu->read("file.sofu");
$sofu->write("file.sofu",\%hash);
$sofu->write("file.sofu",$hashref);
$texta=$sofu->pack($arrayref);
$texth=$sofu->pack($hashref);
$arrayref=$sofu->unpack($texta);
$arrayhash=$sofu->unpack($texth);
DESCRIPTION
This Module provides the ability to read and write sofu files of the versions 0.1 and 0.2. Visit http://sofu.sf.net for a description about sofu.
It can also read not-so-wellformed sofu files and correct their errors.
Additionally it provides the ability to pack HASHes and ARRAYs to sofu strings and unpack those.
SYNTAX
This class does not export any functions, so you need to call them using object notation.
FUNCTIONS AND METHODS
new
Creates a new Data::Sofu object.
setIndent(INDENT)
Sets the indent to INDENT. Default indent is "\t".
setWarnings( 1/0 )
Enables/Disables sofu syntax warnings.
write(FILE,DATA)
Writes a sofu file with the name FILE.
An existing file of this name will be overwritten.
DATA can be a scalar, a hashref or an arrayref.
The top element of sofu files must be a hash, so any other datatype is converted to {Value=>DATA}.
@a=(1,2,3);
$sofu->write("Test.sofu",\@a);
%data=$sofu->read("Test.sofu");
@a=@{$data->{Value}}; # (1,2,3)
read(FILE)
Reads the sofu file FILE and returns a hash with the data.
pack(DATA)
Packs DATA to a sofu string. DATA can be a scalar, a hashref or an arrayref.
unpack(SOFU STRING)
This function unpacks SOFU STRING and returns a scalar, which can be either a string or a reference to a hash or a reference to an array.
BUGS
Hashes with keys other than strings without whitespaces are not supported due to the restrictions of the sofu file format.
Crossreference will trigger a warning.
SEE ALSO
perl(1),http://sofu.sf.net