Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: how do I find the position of an element in an unknown arrayby QwertyD (Pilgrim) |
on Apr 04, 2006 at 18:10 UTC ( [id://541205]=note: print w/replies, xml ) | Need Help?? |
fundflow's suggestion above to use a hash might be a good idea, but what if the order of the elements in the array is important? You can't just use a hash, because hashes do not preserve any kind of order for their entries. What you can use, however, is something like Tie::IxHash which gives you hashes that preserve the order of their entries and upon which you can do array-like operations. Originally posted as a Categorized Answer.
In Section
Seekers of Perl Wisdom
|
|