Sofu Perl Interface

Sofu for Perl comes in two Flavours: Data::Sofu and Config::Sofu.
Data::Sofu provides an interface to read and write .sofu files and convert them to Perl Datastructures.
Config::Sofu provides an easy interface to Configuration files based on Sofu.
Both Modules can easily optained via CPAN and the CPAN Module.

How to get Sofu:

$ perl -MCPAN -e shell
install Data::Sofu
install Config::Sofu

More information on the two Modules and how to use them: Data::Sofu and Config::Sofu Examples

Using this .sofu File (Called 1.sofu):

List = ("One" "Two" "Three") # A list
Map = { 
	SubList = (

Reading the file and getting the Value of "Key"

use Data::Sofu;
my %sofu=readSofu("1.sofu");
print $sofu{Map}->{SubList}->[0]->{Key}; #prints "Value";

Using Config::Sofu

use Config::Sofu qw/1.sofu/;
use vars qw/%CONFIG/;
print $CONFIG{Map}->{SubList}->[0]->{Key}; #also prints "Value";

Writing .sofu files:

delete $hash{Map};
$comments{"List->2"}=["Inserted Comment"];

This will write:

Foo = "Bar"
List = ( # A list
	"Two" #Inserted Comment

It can also be to serialise Data

use Data::Sofu;
my $sofu=new Data::Sofu;
$a={foo=>[0 .. 20]};
print $packed;
$b=$sofu->unpack($packed); #$b has now the same values as $a, but different references.

This can be used to store structered data into databases and read them again with another program. News

Data::Sofu Version 0.28 is out, support for SofuML dropped (for now). Also updated sofu-config to version 0.4 to support binary Sofu files. Updated Documentation to 0.28

Upcoming Version 0.28 of Data::Sofu will support a fully SofuD compatible interface with Data::Sofu::Object and will also include support for BinarySofu files and SofuML

Version 0.27 is finished. It supports Sofu 0.2 language specification and also includes references, it preserves comments and supports undfined values