I really like 2teez hash approach, although I would do it a little differently. Also a couple of array-only approaches. All of these easily generalize to any number of output arrays/groups/whatever. Note that the approach based on List::MoreUtils::part leaves you with a sub-array 0 filled with delimiter dreck.

>perl -wMstrict -le "use List::MoreUtils qw(part); use Data::Dump; ;; my @ra = ( 'CPU Temp = 30', 'GFX Temp = 45', 'RAM Temp = 40', '', 'CPU Status = OK', 'GFX Status = OK', 'RAM Status = OK', ); ;; my $p = 1; my @parts = part { m{ \A \s* \z }xms ? ($p = 2, 0) : $p } @ra; dd \@parts; ;; my @pointer = \my (@ra_1, @ra_2); my $pp = 0; m{ \A \s* \z }xms ? $pp = 1 : push @{ $pointer[$pp] }, $_ for @ra; dd \@ra_1; dd \@ra_2; ;; my %hash; m{ \b (Temp|Status) \b }xms and push @{ $hash{$1} }, $_ for @ra; dd \%hash; " [ [""], ["CPU Temp = 30", "GFX Temp = 45", "RAM Temp = 40"], ["CPU Status = OK", "GFX Status = OK", "RAM Status = OK"], ] ["CPU Temp = 30", "GFX Temp = 45", "RAM Temp = 40"] ["CPU Status = OK", "GFX Status = OK", "RAM Status = OK"] { Status => ["CPU Status = OK", "GFX Status = OK", "RAM Status = OK"], Temp => ["CPU Temp = 30", "GFX Temp = 45", "RAM Temp = 40"], }

In reply to Re: Using the map function by AnomalousMonk
in thread Using the map function by cspctec

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.