in reply to Checking if an item exists in an array before adding a record to it.

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 ...

If the array doesn't change during the process of populating the HTML table, why not unique-ify the array with List::MoreUtils::uniq before processing it? (Update: I.e., don't worry about adding dups.) (Original ordering is preserved by uniq.)

>perl -wMstrict -le "use List::MoreUtils qw(uniq); ;; my @ra = qw(one spam spam spam two spam three four spam spam five); ;; my @unique = uniq @ra; print qq{@unique}; " one spam two three four five