another solution:
while ($l = <DATA>){ $_++ if $l=~m/Some Field/; $a[$_]{$1} = $2 if $l=~m/^(\w+\s\w+)\s*\:\s(\w+\s\w+|\w+)$/; $a[0]{$1} = $1; } foreach $a (@a){ printf "%-15s %-15s %-15s %-15s\n", map{${$a}{$_}} sort {$b =~ +m/S/}keys %$a; } __DATA__ Some Field : some value Another Field: 1234 Different One: 5678 Yet Another : foo line of uninteresting stuff Some Field : some else Another Field: 4321 Different One: 8765 Yet Another : bar more junk Some Field : another value Another Field: 1122 Different One: 5566 Yet Another : baz
it would've been easier not to print the caption line)

In reply to Re: Extracting and manipulating a range of lines by Lennotoecom
in thread Extracting and manipulating a range of lines by joeymac

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.