Re: values of hash of hash



My nummeric key is example only. My real application has keys that mix of text and number.
My problem is, I have to compare data from two projects and find out duplicated data. Two projects presented as two hash. If first level key is different (using exist function), put the whole data attached to it in an array. Currently, I have to access level 2, level 3 keys before getting it's real value. It is not advanced computing. So I want to access all values without using keys. Using "values %hash" just gives me next level hash.


Matija Papec wrote:
On Thu, 01 Sep 2005 11:27:32 +0200, ngoc <ngoc@xxxxxxxxx> wrote:


I have
$hash{1}{2}{3} = 7;
$hash{1}{4}{5} = 6;
I want to get 7 and 6 without using three for loop and keys function
How can I do it?


use Data::Dumper;
my $s = Dumper \%hash;
my @numbers = $s =~ /([76])/g;

:)

btw, is there a reason for using a hash? perhaps you could be better
with arrays (all you keys are numeric).


.



Relevant Pages

  • Re: Suggestion for an AES Based Hash Function
    ... amateurs posting here seem to favour cyphers, I go for hash functions. ... Rather than trying to use a strong one-way compression function would ... I have used a fixed set of keys in two places. ... preferred to have the first round keys fixed and to start deriving ...
    (sci.crypt)
  • Re: hash tables, non-random keys
    ... I have a hash table that will be containing a non-uniform distribution ... The keys will be inserted sequentially, ... would just use an array. ... something I also sometimes do is to use a small hash to optimize lookups ...
    (comp.programming)
  • Re: HOA redundancy in array.
    ... creates a new hash called $saw. ... corresponding to the given keys. ... [Given that @HOH_protein is an array, therefore $pro_name is a number, ... for my $got (@uniqs) { ...
    (comp.lang.perl.misc)
  • Re: populating a hash with % used as the key and F string as the value
    ... > keys %lookup; ... it states one cannot push or pop a hash on page 10 ... itself is the reference to the array (read: an arrayref). ...
    (perl.beginners)
  • Re: maintaining order in a hash (without Tie::IxHash)
    ... Save the keys in a separate array and iterate over the array. ... >> is the simplest approach at the expense of duplicate storage of the ... accessing a large hash by sorting a ...
    (comp.lang.perl.misc)