Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: TOTAL Element understanding - Why and how to use this?

by chandantul (Scribe)
on Apr 23, 2019 at 01:16 UTC ( [id://1232885]=note: print w/replies, xml ) Need Help??


in reply to Re: TOTAL Element understanding - Why and how to use this?
in thread TOTAL Element understanding - Why and how to use this?

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; }

Replies are listed 'Best First'.
Re^3: TOTAL Element understanding - Why and how to use this?
by hdb (Monsignor) on Apr 23, 2019 at 07:40 UTC

    I have replaced the 'TOTAL' with a more "speaking" label. Pls look at the 'all...' rows and how they represent the sums of the (random) data in each of the blocks:

    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"; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found