http://qs1969.pair.com?node_id=193448


in reply to best data structure

I'm not sure if it's exactly what you were looking for, but I used the built-in perl function grep to examine my list for entries that are already in there. Here's the snippet of code I used to test the grep function:
# Create an initial list @list = (9,2,3,4,5,6); # Data we wish to insert @insert_data = 4..9; # For every datum that we wish to # insert, check for it's existance # in the list and append it if it is # not found foreach $item (@insert_data){ next if grep /$item/, @list; push @list, $item; } # Print out our final list foreach $item (@list){ print $item, ","; }

This results in the output: 9,2,3,4,5,6,7,8.

Hope this helps -- Rolly

Update: See comments below for reasons why this isn't an efficient solution.