Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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;

output

$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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2019-11-19 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (94 votes). Check out past polls.

    Notices?