If I understand you correctly, you're after a pseudo-merge of the 3, row-aligned, arrays contained within @results - where ...

If so, then maybe something along the following (untested) lines might suffice ...

use strict; use warnings; use Data::Dumper; my @results; while (<DATA>) { my @row = split; for (my $idx = 0; $idx < 3; $idx++) { push @{ $results[$idx] }, $row[$idx]; } } # Assume @results already populated... my ($day_of_week, $production_line, $output) = @results; my @data_to_plot; # Ignore the headers for (my $idx = 0; $idx < 3; $idx++) { shift @{ $results[$idx] } } ### # Extending an idea from [http://www.perl.com/doc/FAQs/FAQ/oldfaq-html +/Q5.4.html]... my %saw; my %production_lines = ( map { $_ => [] } grep ! $saw{$_}++, @$product +ion_line ); # ### for (my $index = 0; $index < @$day_of_week; $index++) { push @{ $data_to_plot[0] }, $day_of_week->[$index] unless grep /^$day_of_week->[$index]$/, @{ $data_to_plot[0] }; push @{ $production_lines{$production_line->[$index]} }, $output-> +[$index]; } push @data_to_plot, ( map { $production_lines{$_} } sort keys %product +ion_lines ); print Dumper \@data_to_plot; __DATA__ DayOfWeek ProductionLine Output 2 CANNING 18353 2 MULTIPACK 14878 2 QUEST 911 3 CANNING 46775 3 MULTIPACK 42601 3 QUEST 1564 4 CANNING 81302 4 MULTIPACK 67542 4 QUEST 1879 . .
results in...
!perl fred.pl $VAR1 = [ [ '2', '3', '4' ], [ '18353', '46775', '81302' ], [ '14878', '42601', '67542' ], [ '911', '1564', '1879' ] ];

Once more, sits back and awaits flames for bad code, style, karma etc...

Update:
Corrected typos
Tested - corrected 'features', added results

HTH ,

A user level that continues to overstate my experience :-))

In reply to Re: Variables as a variable name... (I know you shouldn't but...) by Bloodnok
in thread Variables as a variable name... (I know you shouldn't but...) by 2mths

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.