Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks. A couple of comments:
  • Checking for Dump/Load is prudent, but all of the listed YAML modules implement the common Dump/Load API, so I don't think it's absolutely necessary.
  • The check for Dump/Load in your last version assumes the included module uses @EXPORT. I wouldn't rely on that, as there are alternates to Exporter which don't use that, and while these modules might currently use it, that behavior is not in the API. If they switch to something else, this'll break.

    A better way might be to perform an explicit import, e.g. something like

    eval { $yaml_class->import( 'Dump'); 1; } or croak( "Can't find Dump in $yaml_class\n" );
    or, if you can trust that the function isn't AUTOLOADED, look at the module's namespace for the function
    Package::Stash->new( $yaml_class )->has_symbol( '&Dump' ) or croak( "Can't find Dump in $yaml_class\n" );
    The only foolproof method is to just wait for a runtime error:
    my $Dump = $yaml_class . "::Dump"; [... later in the code ...] my $var = eval { &$Dump(...) } or croak( "bad return or Dump not imple +mented\n" );
There's also another problem, which I didn't recognize until late last night (and didn't get around to posting about before your reply), namely that if there's a YAML module already loaded, it should use that. I've updated the OP above to illustrate my current code.

In reply to Re^2: What's the best way to use Any YAML (not YAML::Any) by djerius
in thread What's the best way to use Any YAML (not YAML::Any) by djerius

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 or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2022-05-17 15:01 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (66 votes). Check out past polls.