What you've posted here is pretty much an exact duplicate of Re^24: Unable to create a Pivot chart with visiable Columns from seven months ago, it would have been good if you had linked to that thread for context. So that we don't have to re-read that entire thread, it would be best if you could provide context to your question - see How do I post a question effectively? and Short, Self-Contained, Correct Example.
In general, please use <p> tags instead of <code> tags for text; the latter should be used for code, sample input, and output. Also, you posted this in Perl Monks Discussion, the correct section for questions is Seekers of Perl Wisdom (I have moved your post, please don't re-post).
| [reply] [d/l] [select] |
At a first glance it looks like the code is doing some counting and is doing sums by certain categories. Highest level is by app, then by device, then by browser. Wherever you see 'TOTAL' in a particular column, it means that the distinction between different devices, say, is ignored, and a total across all devices is done. Same for app and browser.
| [reply] |
Thanks for your responses! I would like to understand more in details, If you are telling highest is app label ( CGA,HGS,YAG, TAG) then device label (Computer,Mobie) then browser label (IE11,CHROME,EDGE), In the loop, its checking the counts for %pivot hash by $pivot{$app}{$device}{$browser}; ? Can you please elaborate the difference between following code snippet about which sum its doing ++$pivot{$app}{'TOTAL'}{$browser}; ( is this counting total app counts and what about the browser here? Please let me know about this too ++$pivot{$app}{'TOTAL'}{'TOTAL'}; Please check entire for loop
for ($k = 0; $k <= $#responseid; $k++) {
next if ($responseclientbrowser[$k] =~ /IE7/i);
$worksheet1->write($row1,0, $responseid[$k],$format2);
$worksheet1->write($row1,1, $responsdisp[$k],$format2);
$worksheet1->write($row1,2, $responsalter[$k],$format2);
$worksheet1->write($row1,3, $responseclientdevice[$k],$format2
+);
$worksheet1->write($row1,4, $responseclientbrowser[$k],$format
+2);
$worksheet1->write($row1,5, $responseapps5[$k],$format2);
$worksheet1->write($row1,6, $estdate[$k],$format2);
$app = $responseapps5[$k];
$device = $responseclientdevice[$k];
$browser = $responseclientbrowser[$k];
$userid = $responseid[$k];
#print Dumper $browser;
++$pivot{$app}{$device}{$browser};
#print Dumper ++$pivot{$app}{$device}{$browser};
++$pivot{$app}{'TOTAL'}{$browser};
# print Dumper ++$pivot{$app}{'TOTAL'}{$browser};
++$pivot{$app}{'TOTAL'}{'TOTAL'};
#print Dumper $pivot{$app}{'TOTAL'}{'TOTAL'};
++$pivot{$app}{$device}{'TOTAL'};
++$pivot{'TOTAL'}{$device}{$browser};
#print Dumper $pivot{'TOTAL'}{$device}{$browser};
#++$pivot{$app}{$browser};
++$categ{'device'}{$device};
++$categ{'browser'}{$browser};
++$app{$app};
$row1++;
#print Dumper $app;
}
| [reply] [d/l] |
use strict;
use warnings;
use Data::Dumper;
my %pivot;
# generate 100 random records for app(lications) being accessed thru s
+ome dev(ices) with some bro(wsers)
for(1..100){
my($app,$dev,$bro) = (qw(App1 App2 App3)[rand 3],qw(Dev1 Dev2 Dev3
+)[rand 3],qw(Bro1 Bro2 Bro3)[rand 3]);
++$pivot{$app}{$dev}{$bro};
++$pivot{'allapps'}{$dev}{$bro};
++$pivot{$app}{'alldevs'}{$bro};
++$pivot{$app}{$dev}{'allbros'};
++$pivot{'allapps'}{'alldevs'}{$bro};
++$pivot{$app}{'alldevs'}{'allbros'};
++$pivot{'allapps'}{$dev}{'allbros'};
++$pivot{'allapps'}{'alldevs'}{'allbros'};
}
# statistics for accesses
for my $app (sort keys %pivot) {
for my $dev (sort keys %{$pivot{$app}}) {
for my $bro (sort keys %{$pivot{$app}{$dev}}) {
print "$app\t$dev\t$bro\t$pivot{$app}{$dev}{$bro}\n";
}
print "------------------------------------------------\n";
}
}
| [reply] [d/l] |