Re: hash of arrays question



I'm new to perl and have a question. The perl book
says that hashes map keys to values. Using the reverse
function you can map values to keys.

AFAIK, the reverse function takes a list/array, and returns
it in the opposite order.



My problem is
I have a hash of arrays and I want to map an array
of values to a particular key. Is there any way to
do this?

Something like this?

@contents = (1,2,3,4,5)
$hashofarrays{key} = \@contents

I can then reference like follows:

print $hashofarrays{key}[2]

outputs: 3


.



Relevant Pages

  • hash of arrays question
    ... The perl book ... says that hashes map keys to values. ... I have a hash of arrays and I want to map an array ...
    (comp.lang.perl)
  • Re: How to compare hashes to find matching keys with conflicting values.
    ... I did read the perldoc info on map but I am> still confused on how it is being used here. ... I would have now way to link them back to the keys> from register as now they would be numerically ordered in the array instead> of being linked to the hostname key. ... The keys of %keys are sorted with it before it goes through the "map pipe". ...
    (perl.beginners)
  • RE: How to compare hashes to find matching keys with conflicting values.
    ... How to compare hashes to find matching keys with conflicting ... I see that we are creating an array called res however I ... I did read the perldoc info on map but I ... from register as now they would be numerically ordered in the array ...
    (perl.beginners)
  • Re: Why doesnt Integer have a setValue(int i), and is there a way of changing its value.
    ... With immutable keys, ... The alternative to immutability would ... Now, I assume that the second Integer added to the Map, will return an int value ... > this has the potential of being a security problem. ...
    (comp.lang.java.programmer)
  • Re: Help with sorting values in a TreeMap
    ... > the map is an AccountView object whose 'getKey' method returns the ... > I use TreeMap so that they sort nicely by the account number. ... When you construct a TreeMap with a Comparator, ... The objects that it would be comparing _are_ the keys that you described, ...
    (comp.lang.java.programmer)