in reply to Find array duplicates

First of all, unless you are changing $table_name in the loop and don't want @tables to also change, try this instead: foreach my $table_name (@tables) if your version of perl supports the "foreach my $foo" syntax. I strongly doubt you want to say "my @tables", since this will refer to a new empty array, not whatever @tables means outside the loop.

If your excluded names are keys in hash, you can just say

unless ($excluded_table{$table_name}) { do assignments }
If you need the excluded names in an array, try perldoc -q 'contained in a'