Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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} ); } }

In reply to Human readable/writable serialization alternatives to YAML and XML ? by mandog

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (3)
    As of 2021-04-11 13:06 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found