No such thing as a small change | |
PerlMonks |
Checking if an item exists in an array before adding a record to it.by viffer (Beadle) |
on Aug 10, 2013 at 14:59 UTC ( [id://1048909]=perlquestion: print w/replies, xml ) | Need Help?? |
viffer has asked for the wisdom of the Perl Monks concerning the following question:
Hi people.. I'm populating an array, which I then use in a foreach statement to print into an html table. The issue I have is that I'm getting duplicates in the array, so basically I want to check if the item exists in the array and then only add the new record if it doesn't exist. I've tried turning the array into a hash, which works, but it seems to be a waste of time to drop the array into a hash every single time I need to check it. Is there a quicker, more efficient way to do it? I suspect using grep would be even slower. Thanks all
Back to
Seekers of Perl Wisdom
|
|