in reply to hash 2 array ?
I would use Tie::IxHash or something like it, but here's a possibility not mentioned:
For everything you insert into the hash, keep an array by its side. You can then use it in a hash slice. Example:
my %hash; my @hash_array; $hash{key1} = 'value1'; push @hash_array, 'key1'; $hash{key2} = 'value2'; push @hash_array, 'key2'; . . . # Fetch the values. Notice that '%hash' has # an array sigil. my @values = @hash{@hash_array};
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
|---|