Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (11)
As of 2024-04-18 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found