This should get you started.
It's up to you to figure out why I am not putting things in hash(es).
use strict; my (@up, @down, @labels); while (<DATA>) { chomp; if (/Peripherals Down:$/i .. /Peripherals Up:$/i) { next if /^$|^-{4}|Peripherals /; if (/^name/i){ @labels = split /\s\s+/; next; } my %h; @h{@labels} = split /\s\s+/; push @down, \%h; }else { next if /^$|^-{4}/; if (/^name/i){ @labels = split /\s\s+/; next; } my %h; @h{@labels} = split /\s\s+/; push @up, \%h; } } use Data::Dump qw/pp/; print "Down: $/"; pp @down; print "Up: $/"; pp @up; __DATA__ Peripherals Down: Name Host Port Category Priority + Monitor Type IS Managed Down time ---- ---- ---- -------- -------- + ------------ ----------- ------------ Christine 62.01.22.100 0 ABC company High + Ping Yes Thu Dec 16 06:35:07 PST 2004 Clark 72.03.100.89 0 XYZ company Low + Ping Yes Thu Dec 16 06:35:16 PST 2004 Peripherals Up: Name Host Port Category Priority + Monitor Type IS Managed Up time ---- ---- ---- -------- -------- + ------------ ----------- --------- Laston 100.02.99.211 0 XYZ company Medium + Ping Yes Thu Dec 16 06:35:27 PST 2004
HTH
--
Olivier

In reply to Re: Parsing email and returning the key/values in two hashes by olivierp
in thread Parsing email, inserting into database and creating an aggregation report. by Alligator

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.