Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: non-scalar hash key

by McDarren (Abbot)
on Jun 17, 2009 at 09:55 UTC ( #772311=note: print w/ replies, xml ) Need Help??


in reply to non-scalar hash key

Sounds like you need a HoA (hash of arrays).

Check out the PDSC

Cheers,
Darren :)


Comment on Re: non-scalar hash key
Re^2: non-scalar hash key
by Anonymous Monk on Jun 17, 2009 at 09:57 UTC
    I think he want array of integers to become key, not value
      exactly
        ah, okay.

        Well, a reference to an array is a scalar. So, perhaps something like:

        my @foo = qw/1 2 3 4 5 6/; my %bar = ( \@foo => 'elephants', ); my $zonk = \@foo; print "$bar{$zonk}\n";
        prints:
        elephants

        Cheers,
        Darren :)

        I'm wondering why this is so difficult. If you take a string as the key to a hash, that string is actually an array of bytes, which is probably searched for by the C function strcmp. Now all I want is an array of which the elements are a tad larger (4 bytes iso 1 byte, because I need unsigned longs), and possibly another hash function (hashword in http://burtleburtle.net/bob/c/lookup3.c) and another comparison function similar to strcmp but working on integers.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (14)
As of 2015-07-06 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (75 votes), past polls