hi i have achieved the desired output by using the following code.I tried to store the output in a variable and get average out of it but could not.Can some one help me out
#!/usr/bin/perl
use strict;
use warnings;
use IO::All;
#use Data::Dumper;
my @lines = io('Salesofcar.txt')->chomp->slurp;
splice @lines, 0, 1; # remove first line
my %hash;
foreach my $line (@lines) {
$line =~ s/^\s+//;
my @cols = split /\s+/, $line;
my $key = join '-',splice @cols, 0, 2;
my %com;
@com{qw( In2017 In2018 In2019} = @cols;
$hash{$key} = { %com };
}
use Data::Dumper; $Data::Dumper::Sortkeys=1;
print Dumper(\%hash);