in reply to Re: hash of hash
in thread hash of hash
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: hash of hash
by hippo (Archbishop) on Feb 17, 2019 at 16:55 UTC | |
|
Re^3: hash of hash
by choroba (Cardinal) on Feb 17, 2019 at 16:52 UTC | |
by Tigor (Novice) on Feb 18, 2019 at 04:46 UTC | |
by marto (Cardinal) on Feb 18, 2019 at 07:44 UTC |