http://www.perlmonks.org?node_id=748952

mandog has asked for the wisdom of the Perl Monks concerning the following question:

What good human readable/writable data serialization options with good Perl support are there?

We're completely happy with Config::Simple and .ini files for the configuration info for our application.

Now we want to re-factor our Test::WWW::Mechanize tests so the test data is easier to follow, perhaps by separating test code from test data. I'm surprised that there isn't an obvious choice.

The popular serialization modules Storable and FreezeThaw are binary.

XML doesn't seem very human readable. There are 39 pages of results for the google query "xml sucks". There is even a web site devoted to that assertion.

YAML looks a bit better but the documentation is a bit thin. For example YAML::Manual::Tutorial is a line of text: "not yet been written." Worse there are a few apparently serious years old bugs. This could be an easy opportunity for us to contribute documentation...

JSON::XS doesn't look bad. There seems to be a good bit of example code, but I'm not seeing how JSON is much more readable than Perl

I'm begining to think that for us Perl is actually more writeable/readable than XML,YAML,JSON,etc. Also, we don't have to learn something new to use Perl. Maybe we should put the test code in a module and move each sub that returns an array of test data into its own .t file. Simplifying somewhat and perhaps introducing syntax errors, our existing code is:

my @forms_no_password = forms_with_no_password($host); my @forms_to_add_agency = forms_to_add_agency($host); my @other_group_of_related_forms = other_group_of_related_forms($ho +st); submit_forms_ok( $mech, @forms_no_password ); # .... sub forms_with_no_password { my $host = shift; my @forms = ( { 'test_description' => "search_phrase='' category_search_fo +rm", 'url' => "http://$host/", 'expected_content' => "Sorry, we don't have any program categories", 'number' => '1', 'button' => 'Search', 'fields' => {}, }, { 'test_description' => "search_phrase='' agency_search_form +", 'url' => "http://$host/", 'expected_content' => "know of any agency whose name match +es", 'number' => '2', 'button' => 'Search', 'fields' => {}, }, ); } sub submit_forms_ok { my ($mech,@forms) @_; my %params; for my $form (@forms) { $params{form_number} = $$form{number}; $params{fields} = $$form{fields}; $params{button} = $$form{button}; $mech->get( $$form{url} ); $mech->submit_form_ok( \%params,$$form{test_description} ); $mech->content_contains( $$form{expected_content} ); } }