Suppose I want an array of value pairs, suppose for the sake of arguments, vertices, like X,Y (though, they don't have to be numeric types, I'm thinking generic pairs). I want to keep the list of vertices in a list.
What's the best way to store/organize them in perl?
It seems so wasteful to use an array of hashes (key/value) for a single pair, with key names like X and Y.
%pair = ( X => 12, Y => 10); #then keep in a list like this... $pairlist[0] = \%pair;
And using the first (X) value as a key wouldn't work if you needed to repeat the value.
Of course, a simple array of arrays would work...%pair = (12 => 10); # no list required, but then (12,10) and then (12,5) wouldn't work...
@pair = (12,10); #with a list assigned like... $pairlist[0] = \@pair;
I guess I'm curious what y'all do?
I mean, besides making an object, which is a pain for something this simple, especially if I don't supplement my Perl with something like Moose, which I don't... (well maybe it's not a pain for you... but I'm pretty weak there...) ;)
In reply to Storing simple Value Pairs by raybies
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |