Link to home
Start Free TrialLog in
Avatar of FireBall
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 :



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

Open in new window

Avatar of David Favor
David Favor
Flag of United States of America image

Post output of print Dumper $hash + likely someone can help you.

Where $hash is what your calling scalar, so the root scalar, to print your entire tree.
Avatar of FireBall
FireBall

ASKER

I need to get biggest value and this value's owner

print Dumper %udp_dst_ip;

Open in new window


$VAR1 = '185.182.188.3';
$VAR2 = {
          'src' => 87
        };
$VAR3 = '185.9.157.211';
$VAR4 = {
          'src' => 1501
        };

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you