This will extract the id & label from each block much more quickly than your code, by reading one block at a time. I didn't understand your hash, so I've left that to you.

#! perl -slw use strict; use Data::Dump qw[ pp ]; $/ = "\n----"; ## read 1 multiline record at a time while( <DATA> ) { my( $label, $id ) = m[ -El \s+ (\S+) .+? serial_id \s+ ( \S+ ) ]xms or die 'Bad data'; print "$label : $id"; } __DATA__ ---- lsattr -El vgbkup ---- auto_on y N/A True conc_auto_on n N/A True conc_capable n N/A True gbl_pbufs_ppv 0 N/A True gbl_pbufs_pvg 0 N/A True timestamp 49188ced308665bd N/A True vg_pbufs_ppv 0 N/A True vgserial_id 00c0b42000004c000000011a5f8b013e N/A False ---- lsattr -El vgfrd01 ---- auto_on y N/A True conc_auto_on n N/A True conc_capable n N/A True gbl_pbufs_ppv 0 N/A True gbl_pbufs_pvg 0 N/A True timestamp 4ae7197814a6d91a N/A True vg_pbufs_ppv 0 N/A True vgserial_id 00c0b42000004c000000011a0d27a4bc N/A False ---- lsattr -El loglv02 ---- copies 1 N/A True inter m N/A True intra m N/A True label None N/A True lvserial_id 00c0b42000004c000000011a5f8b013e.2 N/A False relocatable y N/A True size 1 N/A True strictness y N/A True stripe_size N/A True stripe_width 0 N/A True type jfs2log N/A True upperbound 64 N/A True ---- lsattr -El lvbackup ---- copies 1 N/A True inter x N/A True intra im N/A True label /backup N/A True lvserial_id 00c0b42000004c000000011a5f8b013e.1 N/A False relocatable y N/A True size 1200 N/A True strictness y N/A True stripe_size N/A True stripe_width 0 N/A True type jfs2 N/A True upperbound 64 N/A True

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

In reply to Re: Parsing a Large file with no reason by BrowserUk
in thread Parsing a Large file with no reason by mrras25

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.