If the summary is always on a single line and is the second line you could always put the second line directly in the summary and the first line could be parsed for input. If not you will have to take that into account.

What charachters are allowed to appear in the summary? If any charachters can appear and the summary can be multiple lines and it's on a second line because the code is wrapping you will have problems, because you can't split on charachters such as [, ], or :. If you have access to the code of the original CLI you may want to change the output a little bit. I would recommend outputting the results to XML if it's an option. That would make it much easier for you and whoever else needs to parse it to parse it.

Otherwise you may need to get tricky if the worse case scenario for everything I've mentioned is true. You could split on the regular expression: /^.*: [.*?\] \[.*?\] \[.*?\] \[.*?\].*$/ (I think, not tested). You'd then have all of the comments. Or you could read line by line and use that regular expressiong with the $`, $&, $' variables. (That's the thing before the match, the thing that was matched, and the thing after the match). Be warned though that once they're present in code they will be created for all regular expressions which can slow down your code.

Just some thoughts,

Vautrin

In reply to Re: parsing multi-line output from a cli command by Vautrin
in thread parsing multi-line output from a cli command by TASdvlper

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.