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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |