in reply to Re^3: Computing results through Arrays
in thread Computing results through Arrays
Thanks a lot Aaron Sir !!!! I tried coding the way you said but not sure where I am going wrong, getting lot of errors "Use of uninitialized value in string". I tried debugging but in vain. Also no idea how to print the keys in a single line, I am not able to meet this requirement "print them as headers, formatted to fit what's coming below" Please do not mind for these silly mistakes, I am still beginner in perl.
#!/usr/bin/env perl use strict; use warnings; my %h; my %m; my %db; while(<DATA>){ chomp; my @fields = split; my ($date,$database_name,$speed) = @fields[1,2,3]; my ($date_hour,$minute) = split /:/, $date ; my $date_hour_minute = join (':',$date_hour,$minute) ; $h{$date_hour}{$database_name} += $speed; $m{$date_hour_minute}{$database_name} += $speed; $db{$database_name} = 1; } for my $db_keys (sort keys %db){ print "$db_keys"; for my $h_keys (sort keys %h){ print $h_keys; for my $db_keys (sort keys %db){ print "$h{$h_keys}{$db_keys}"; print "\n"; } } }
Will be thankful to you if you could help me please...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Computing results through Arrays
by aaron_baugher (Curate) on Jun 05, 2015 at 18:44 UTC | |
by yasser8@gmail.com (Novice) on Jun 05, 2015 at 20:51 UTC | |
by aaron_baugher (Curate) on Jun 05, 2015 at 21:31 UTC | |
by yasser8@gmail.com (Novice) on Jun 07, 2015 at 06:02 UTC | |
by aaron_baugher (Curate) on Jun 07, 2015 at 14:37 UTC | |
|