Alternately, you can play with the input record separator to get the chunks you need.

use strict; use warnings; use Data::Dumper; my @filesys; { local $/ = '--- Logical extents ---'; while ( my $record = <DATA>) { chomp $record; next unless $record =~ /--- Logical volumes ---/; $record =~ s/^.*--- Logical volumes ---\n//s; my ($beginning, $end) = split /--- Distribution of logical volum +e ---/, $record; my %params = split / +|\n/, $beginning; my @lines = split /\n/, $end; for my $line(@lines) { next if $line =~ /PV Name/; next if $line !~ /\S/; my ($name, $le, $pe) = split ' ', $line; push @{$params{PV}}, {'Name', $name, 'LE on PV', $le, 'PE on + PV', $pe}; } push @filesys, \%params; } } print Dumper \@filesys; __DATA__ <---snipp---> --- Logical volumes --- LV Name /dev/vg00/lvol3 VG Name /dev/vg00 LV Permission read/write LV Status available/syncd Mirror copies 1 Consistency Recovery MWC Schedule parallel LV Size (Mbytes) 300 Current LE 75 Allocated PE 150 Stripes 0 Stripe Size (Kbytes) 0 Bad block off Allocation strict/contiguous IO Timeout (Seconds) default --- Distribution of logical volume --- PV Name LE on PV PE on PV /dev/dsk/c3t6d0 75 75 /dev/dsk/c38t6d0 75 75 --- Logical extents --- Some other bogus crap that needs to be ignored. --- Logical volumes --- LV Name /dev/vg00/lvol33 VG Name /dev/vg003 LV Permission read/write LV Status available/syncd Mirror copies 1 Consistency Recovery MWC Schedule parallel LV Size (Mbytes) 500 Current LE 70 Allocated PE 150 Stripes 0 Stripe Size (Kbytes) 0 Bad block off Allocation strict/contiguous IO Timeout (Seconds) default --- Distribution of logical volume --- PV Name LE on PV PE on PV /dev/dsk/c3t6d03 75 75 /dev/dsk/c38t6d03 75 75 --- Logical extents --- <---snip--->

In reply to Re: Getting only part of a text file... by thundergnat
in thread Getting only part of a text file... by svnipp

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.