I need help with parsing a file and placing certain elements into a hash of hashes. The file I am parsing is always different based on host that the file is pulled from and basically it is a lsattr with an lsdev –C command ran after it – All I care about is the lines that read like:

............. ---- 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 ...........

The hash would go something like this:

$host_info{VG}{$vgname}{$vgid}{LV}=$lvlabel;

I need the vgname which is vgfrd01, the vgserial_id which is 00c0b42000004c000000011a0d27a4bc and I need to map the label of the lv to the vgserial number which is the same with a “.” Reference at the end.


In reply to 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.