I have sample data such as:
object network Microsoft.Lync.Host.3 host 138.108.25.111 description Help Desk Ticket #476739 object network Microsoft.Lync.Host.4 host 138.108.25.112 description Help Desk Ticket #476739 object network Microsoft.Lync.Host.5 host 138.108.25.113 description Help Desk Ticket #476739 object network Microsoft.Lync.Host.6
I need to extract each object into its own hash that I'll then roll up into an AoH. I have tried changing the delimiter $/ but I think that can only be a static string and each 'object network' line finishes with a unique name. I couldn't find any way to make the delimiter regex based (which I think would solve my problem unless the delimiter is removed/consumed when parsing records). I next thought about reading the whole file to an array and processing records in line batches. However some objects have a description, making it a batch of 3 lines, whereas some don't making it a batch of 2. I suppose I could do some work processing the array to look for whether or not the line has a description, but I feel like I am way over-thinking this. I also tried to extract text between lines, but I don't have unique START/END variables like examples showing the use of range /START/ .. /END/. I tried anyways using a regex match looking for just text between groupings of /object network/ but that was exclusive/destructive and I began to lose records. I can post some code if necessary.

I'm sure one of the Monks here has a solution! Thanks in advance.


In reply to Extract Data Between Lines by namelkcip

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.