Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Output of Output

by Tigor (Novice)
on Feb 18, 2019 at 09:35 UTC ( #1230068=perlquestion: print w/replies, xml ) Need Help??

Tigor has asked for the wisdom of the Perl Monks concerning the following question:

Hi Marto,Please find below code.this code

input file looks as below(sample)

Name test1 test2 kim A 20 30 kate k 40 50
#!/usr/bin/perl use strict; use warnings; use IO::All; use Data::Dumper; #use List::Util qw(sum); #$Data::Dumper::Useqq = 1; my @lines = io('test_Scores.txt')->chomp->slurp; splice @lines, 0, 1; # remove first line my %hash; foreach my $line (@lines) { $line =~ s/^\s+/ /; my @elements = split /\s+/, $line; my $key = join '-',splice @elements, 0, 2; $hash{$key} = \@elements if length($key) > 0; } #Data::Dumper::Useqq = 1; print Dumper \%hash;


$var1 ={ 'kim-a' =>['20', '30'], 'kate-k' =>['40', '50']}

I need to get average from the above output which should be final output and it should look like below

$var1 ={ 'kim-a' =>[25], 'kate-k' =>[45']}

Replies are listed 'Best First'.
Re: Output of Output
by marto (Archbishop) on Feb 18, 2019 at 10:09 UTC

    You've asked several times how to get the average value (e.g. Retrieve average). Please review and action existing responses.

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1230068]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2020-09-18 13:12 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (112 votes). Check out past polls.