I have only used YAML a little as yet but am going to be using it a lot more because of Catalyst and also for non-Catalyst work e.g. for object template configuration or whatever. For simple things I use either Config::IniFiles or more often just a simple tab-separated text file with hash keys (for error messages) though these might all end up in YAML soon.

I thought about setting the input record separator (see perlvar, perlrun) to "---\n" which can be done, but on the command line perl only seems able to set a single character separator with the command line switches. Then I looked at File::Tail. You might like to contact the author is thinking of adding record separator support if you have a good reason for it, and this seems like a good one (or do it yourself and submit back to him later).

Well I fiddled with the command line and got this far: cat test.yml|perl -nla -0777 -F/---/ -e 'foreach $s (@F) {print "***STREAM***$s\n";}'|more but it doesn't work with tail as far as I can see.

So if you want to follow a file, I'd guess either build on File::Tail, or better yet roll your own by reading from a pipe within a perl program. In the past I've used an interactive shell based on Term::Readline to try out multiline scripts with the Gimp, and it worked great. Come to think of it what about ysh? ... and lo and behold I open /usr/bin/ysh and it is using Term::Readline. I would guess the easiest thing to do would be to just modify ysh. I got cat to work with it but not tail, not sure why. Also for some reason it gave a parse error (bad alias) for the long data structure posted in the thread.

Oh, one more datapoint. Boulder is something like yaml made for bioperl, and used in piped workflows. So you aren't the first person to want to do this and it shouldn't be too hard. If I was doing this I would probably just roll my own program I think to watch a file and pull in lines, decoding from yaml when a separator is reached. Term::Readline might do it too. Bioperl does something like what you want and it might even work on yaml files as-is. It's used to slurp in long gene text files.


In reply to Re: YAML for logs? by mattr
in thread YAML for logs? by blazar

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.