P is for Practical | |
PerlMonks |
Is there an easy way to assign guaranteed unique values to a simple array without looping through whole array?by memnoch (Scribe) |
on Nov 29, 2007 at 21:30 UTC ( [id://653982]=perlquestion: print w/replies, xml ) | Need Help?? |
memnoch has asked for the wisdom of the Perl Monks concerning the following question:
UPDATE: Thank you all for your suggestions! I'm all set! memnoch Venerated Monks, I'm wondering if there is a clever way to assign unique values to a simple array without having to loop through the array for each value to be considered. In my situation, there is no way to tell the array position that the possible value might beforehand, so I can't use an index. As an alternative, I have tried using a hash instead, like so: That way, I get unique values. But when I try to retrieve the values with: keys(%hash) I'm not guaranteed to get them in the order that I inserted them. The inserted order is preferred but not essential. Any ideas? Thank you, memnoch
Gloria in Excelsis Deo!
Back to
Seekers of Perl Wisdom
|
|