G'day bliako,

As requested, here's some comments and suggestions.

Naming

Subroutine names with a leading underscore tend to suggest private methods or implementation details; these are generally for internal use and not for users of module, i.e. not part of the interface — _qquote_redefinition_by_Corion() is a part of the implementation and the leading underscore is appropriate. The other four subroutines (_read_from_* and _write_to_*) are, in my opinion, part of the interface — consider removing the leading underscore from these.

Exporting

I wouldn't export those ten subroutines by default (i.e. via @EXPORT); in fact, I wouldn't export anything by default, instead using @EXPORT_OK as recommended in "Exporter: Selecting What to Export".

In addition to using @EXPORT_OK, I would add %EXPORT_TAGS so that users of the module do not have to write long import lists. The following is an example of what can be done; it is not a recommendation of what you should do, although I do think something along these lines is a good idea.

use Exporter 'import'; our (@EXPORT_OK, %EXPORT_TAGS); BEGIN { my @file = qw{read_from_file write_to_file}; my @fh = qw{read_from_filehandle write_to_filehandle}; my @io = (@file, @fh); my @json = qw{perl2json json2perl}; my @yaml = qw{perl2yaml yaml2perl}; my @dump = qw{perl2dump dump2perl}; my @all = (@io, @json, @yaml, @dump); @EXPORT_OK = @all; %EXPORT_TAGS = ( file => [@file], fh => [@fh], io => [@io], json => [@json], yaml => [@yaml], dump => [@dump], all => [@all], ); }

Layout

Some of your code layout could be improved. Lines like this one are not easy to read:

if( ! _write_to_filehandle($FH, $contents) ){ warn "error, call to ".' +_write_to_filehandle()'." has failed"; close $FH; return undef }

That's 134 characters long; plus there's leading whitespace for indentation. This would be much more readable, at least in my opinion, as:

if( ! _write_to_filehandle($FH, $contents) ) { warn "error, call to ".'_write_to_filehandle()'." has failed"; close $FH; return undef; }

— Ken


In reply to Re: RFC: Perl<->JSON<->YAML<->Dumper : roundtripping and possibly with unicode by kcott
in thread RFC: Perl<->JSON<->YAML<->Dumper : roundtripping and possibly with unicode by bliako

Title:
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, details, 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, summary, 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.