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

YAML::Syck:
#!/usr/bin/perl use YAML::Syck; use strict; my $hashref = Load(<<'...'); --- title: This is my title body: | This is some text. Here's a newline: Yet more text. ... print Dump($hashref);
Outputs:
--- body: "This is some text. Here's a newline:\n\nYet more text.\n" title: This is my title
YAML::
#!/usr/bin/perl use YAML; use strict; my $hashref = Load(<<'...'); --- title: This is my title body: | This is some text. Here's a newline: Yet more text. ... print Dump($hashref);
Outputs:
--- body: | This is some text. Here's a newline: Yet more text. title: This is my title
The output of YAML:: w.r.t to the body element is perfect, but YAML:: is a large module and not very efficient. I'd prefer to use YAML::Syck (or something else), but I need the body block formatted correctly (newlines unescaped, no quotation marks on either side, and starting with the bar (|) charcater) in the output because this block, which is potentially very lengthy, will be edited by humans. What options do I have here?

Replies are listed 'Best First'.
Re: YAML::/YAML::Syck and Newlines
by diotalevi (Canon) on Jan 15, 2007 at 04:18 UTC

    I've heard that Python's YAML is getting ported over to perl now. The idea is to steal a particularly good implementation or something like that. If you're up for it, you could help out with that. If you're not, wait til it's done. If that's too long, use YAML because it sounds like it does what you want already.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re: YAML::/YAML::Syck and Newlines
by CountZero (Bishop) on Jan 15, 2007 at 06:56 UTC
    but YAML:: is a large module and not very efficient
    I'd say, not working the way it is supposed to work is the pinnacle of not efficient and by that count, YAML:: is more efficient than YAML::Syck.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law