Sponsored Content
Top Forums Shell Programming and Scripting Compare values of hashes of hash for n number of hash in perl without sorting. Post 302713123 by asak on Wednesday 10th of October 2012 09:55:54 AM
Old 10-10-2012
Error Compare values of hashes of hash for n number of hash in perl without sorting.

Hi,

I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all .
Code:
my %result (
		$abc => {
				 'data_count' => '10',
				 'ID'		  => 'ABC122',
				}
				
		$def => {
				 'data_count' => '20',
				 'ID'		  => 'defASe',
				 }
				 
		:
		:
		:
		
		$n	=> {
				 'data_count' => '20',
				 'ID'		  => 'nsnsn',
			   }
		);

I need to compare the data_count of each hashes of hash, i need to get greater data_count and ID and also lesser( minimum ) data_count and ID.

how to compare the hash values without sorting using perl.

Regards,
asak
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print Entire hash list (hash of hashes)

I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes). Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash. Most of the printing seems to be OK but in... (1 Reply)
Discussion started by: Alalush
1 Replies

2. Shell Programming and Scripting

perl hash of hashes from database

hi there, I have some database output that looks like this SELECT nic_name,nic_duplex,nic_speed,nic_ip FROM network_table WHERE hostname = "server1" result is this (ive delimited with a pipe for ease of reading) bge0|full|1000|10.32.100.1 bge1|full|1000|11.12.101.7 ... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

3. Shell Programming and Scripting

PERL - printing a hash of hashes to screen

Hi there I have a hash of hashes made up of the following data bge0|100|half|10.36.100.21 bge1|1000|full|10.36.100.22 bge2|1000|full|10.36.100.23 which when i turn into a hash, would look like this inside the system bge0 -> nic_speed -> 100 nic_duplex -> half ... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

4. Shell Programming and Scripting

PERL - another quick hash of hashes question

Hi, sorry, two hash related questions in one day .. but this has got me a bit stuck. I have a mysql database table that kind of looks like this, the table is called "view1" and a snippet of that table (SELECT'ing just rows with serial number 0629AN1200) is below serial nic_name ... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

5. Shell Programming and Scripting

Perl Hash:Can not keep hash data in the same order that it was inserted

Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below. #!/usr/bin/perl use warnings; use Tie::IxHash; use strict; tie (my %programs, "Tie::IxHash"); while (my $line = <DATA>) { chomp $line; my(... (1 Reply)
Discussion started by: jgfcoimbra
1 Replies

6. Shell Programming and Scripting

Sorting keys of a hash in perl

hi all, i have a small problem regarding sorting the keys in a hash. my %hash; for($i=0;$i<19;$i++) { $hash{$i}=$i; } foreach $c (sort keys %hash) { print "\n $hash{$c}"; } (1 Reply)
Discussion started by: niteesh_!7
1 Replies

7. Shell Programming and Scripting

perl: dereferencing a hash of hashes

Hi there, I am trying to dereference my hash of hashes but post dereferencing, it seems to lose its structure I am using Data::dumper to help me anaylise. This is the code im using to build the HoH, (data comes from a file). I have also performed a Dumper on the data structure before and after... (1 Reply)
Discussion started by: rethink
1 Replies

8. Shell Programming and Scripting

Perl: Sorting a hash value that is a list.

Hi Folks I am very much a newbie at perl but picking it up and I'm hoping you can help. I have a file input that details all the /etc/group files in our enterprise in the following format: "<host>:<group>:<gid>:<users>" I want to parse this data display it as the following:... (9 Replies)
Discussion started by: g_string
9 Replies

9. Shell Programming and Scripting

Sorting values of hash in ascending order using Perl

I want to sort values of a hash in ascending order. my %records; for my $value (sort values %records){print $value,"\n";} When I use the above code I get values in this order: 1,10,11,2,3,4,5,6,7,8,9. But, I need values in my output in this order: 1,2,3,4,5,6,7,8,9,10,11. Can Someone... (1 Reply)
Discussion started by: koneru_18
1 Replies

10. Shell Programming and Scripting

Perl hash of hashes anonymous array

Hello experts. I'm having problems with a snippet of code. I was hoping to get help/advice to correct. A file that this script parses has changed to the point where I can no longer use a scalar, it looks as though I need to create an array for a hash of hashes below. The first output of... (1 Reply)
Discussion started by: timj123
1 Replies
Hash::Case(3pm) 					User Contributed Perl Documentation					   Hash::Case(3pm)

NAME
Hash::Case - base class for hashes with key-casing requirements INHERITANCE
Hash::Case is a Tie::StdHash Hash::Case is extended by Hash::Case::Lower Hash::Case::Preserve Hash::Case::Upper SYNOPSIS
use Hash::Case::Lower; tie my(%lchash), 'Hash::Case::Lower'; $lchash{StraNGeKeY} = 3; print keys %lchash; # strangekey DESCRIPTION
Hash::Case is the base class for various classes which tie special treatment for the casing of keys. Be aware of the differences in implementation: "Lower" and "Upper" are tied native hashes: these hashes have no need for hidden fields or other assisting data structured. A case "Preserve" hash will actually create three hashes. The following strategies are implemented: o Hash::Case::Lower (native hash) Keys are always considered lower case. The internals of this module translate any incoming key to lower case before it is used. o Hash::Case::Upper (native hash) Like the ::Lower, but then all keys are always translated into upper case. This module can be of use for some databases, which do translate everything to capitals as well. To avoid confusion, you may want to have you own internal Perl hash do this as well. o Hash::Case::Preserve The actual casing is ignored, but not forgotten. METHODS
Constructors $obj->addHashData(HASH) Add the data of a hash (passed as reference) to the created tied hash. The existing values in the hash remain, the keys are adapted to the needs of the the casing. $obj->addPairs(PAIRS) Specify an even length list of alternating key and value to be stored in the hash. $obj->setHash(HASH) The functionality differs for native and wrapper hashes. For native hashes, this is the same as first clearing the hash, and then a call to addHashData(). Wrapper hashes will use the hash you specify here to store the data, and re-create the mapping hash. tie(HASH, TIE, [VALUES,] OPTIONS) Tie the HASH with the TIE package which extends Hash::Case. The OPTIONS differ per implementation: read the manual page for the package you actually use. The VALUES is a reference to an array containing key-value pairs, or a reference to a hash: they fill the initial hash. example: my %x; tie %x, 'Hash::Case::Lower'; $x{Upper} = 3; print keys %x; # 'upper' my @y = (ABC => 3, DeF => 4); tie %x, 'Hash::Case::Lower', @y; print keys %x; # 'abc' 'def' my %z = (ABC => 3, DeF => 4); tie %x, 'Hash::Case::Lower', \%z; SEE ALSO
This module is part of Hash-Case distribution version 1.02, built on March 09, 2012. Website: http://perl.overmeer.net/hash-case/ LICENSE
Copyrights 2002-2003,2007-2012 by Mark Overmeer. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2012-03-09 Hash::Case(3pm)
All times are GMT -4. The time now is 06:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy