I have been trying to format a file which contains lines like the ones below over and over again.
answer-group mark.example.com owner "example" type vip answer-add 10.0.0.1 name mark1.example.com weight 1 answer-add 10.0.0.2 name mark2.example.com weight 1 answer-add 10.0.0.3 name mark3.example.com weight 1 answer-group jeff.example.com owner "example" type vip answer-add 10.0.0.9 name jeff1.example.com weight 1 answer-add 10.0.0.15 name jeff2.example.com weight 1
I would just like to format this file with a script so that the output looks like as follows:
mark.example.com,10.0.0.1,10.0.0.2,10.0.0.3 jeff.example.com,10.0.0.9,10.0.0.15
I have been testing this out using "while" or "foreach" loops while also using "split" to get the specific IP and/or example.com names, but I cannot get the script to output the data in the same line while reading from a filehandle. Any help here would be appreciated.

In reply to Format lines in a File to be outputted in a different sequence by markgoz

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.