FireBall
asked on
Max same object in a scalar
Hello
We have 2 layered scalars like
$scalar1{scalar2}{scalar3}
values sth like that
bbb -> 15
bbb -> 17
bbb -> 14
bbb -> 15
ccc -> 16
ccc -> 16
ccc -> 14
ccc -> 13
ccc -> 16
We need to find that the maximum counts like that
bbb -> 15 (2 times)
ccc -> 16 (3 times)
should some body help us to deal with that , we are now using sth. like this but it is very slow :
We have 2 layered scalars like
$scalar1{scalar2}{scalar3}
values sth like that
bbb -> 15
bbb -> 17
bbb -> 14
bbb -> 15
ccc -> 16
ccc -> 16
ccc -> 14
ccc -> 13
ccc -> 16
We need to find that the maximum counts like that
bbb -> 15 (2 times)
ccc -> 16 (3 times)
should some body help us to deal with that , we are now using sth. like this but it is very slow :
$udp_packet_length{%udp_dst_ip}{ sprintf("0x%X", trim($packet_length))}{src}++;
my $udp_packet_length_max=0;
foreach $key_udp_packet_length (keys %{$udp_packet_length{$key_udp_dst_ip}} ){
my $yeni = $udp_packet_length{$key_udp_dst_ip}{$key_udp_packet_length}{src};
if($yeni>$udp_packet_length_max){
$udp_packet_length_max=$yeni;
$udp_packet_length=$key_udp_packet_length;
}
}
ASKER
I need to get biggest value and this value's owner
print Dumper %udp_dst_ip;
$VAR1 = '185.182.188.3';
$VAR2 = {
'src' => 87
};
$VAR3 = '185.9.157.211';
$VAR4 = {
'src' => 1501
};
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
Where $hash is what your calling scalar, so the root scalar, to print your entire tree.