Ok, thank you,

Ok, second take, lets try like this , slightly less socratic, trying not to figure out where you're stuck, but pretending as if this is your first step in solving this problem, and you're using computer instead of pencil and paper

Please fill in the blanks in program below , edit sub UsedToBeJustDoWork

Create however many variables you need, change whatever names you want, in the end the program should run and produce the data structure you want your program to have

you should not use foreach or while, just type out the vars and math you need to get the correct by your definition of $final_output_wanted

#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; Main( @ARGV ); exit( 0 ); sub Main { UsedToBeJustDoWork(); } sub UsedToBeJustDoWork { my $full_data = [ ["M11", 0.1, 10, 24, 56, 77, 98, 72], ["M12", 0.3, 13, 44, 23, 45, 56, 11], ["M13", 0.4, 54, 23, 11, 25, 67, 91], ]; my $d_to_h = [ [ 24, 56, 77, 98, 72], [ 44, 23, 45, 56, 11], [ 23, 11, 25, 67, 91], ]; ## I don't know what you want here my $these_first_row_average = $d_to_h->[0] + $d_to_h->[1] + $d_to_ +h->[2] + $d_to_h->[3] + $d_to_h->[4] / 4; my $final_output_wanted = [ ## I don't know what you want here $these_first, $these_second, $these_third, ]; dd( $final_output_wanted ); }

In reply to Re^11: How to store the output from foreach loop into variable/array without printing? by Anonymous Monk
in thread How to store the output from foreach loop into variable/array without printing? by hellohello1

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.