Q:

Issue regarding string comparisons and references in perl

Here is where I begin.  I am reading arrays from a database one at a time using a while loop.  I want to pick up on elements from the database that are duplicates (on certain fields).  I want to keep only the items that are unique on these fields.  Then I want to print out the data I have kept in a certain way.  I created the code I thought would do it, but it gives me everything including items which are duplicates on the field.  I've been searching and searching and I can't figure it out, I'm thinking, as a perl noob, I am missing something simple.  Code is as follows:
my @uniques = ();
my $output;

while (my @itemArray = $sth->fetchrow_array() ) {
    my $duplicateFlag = 0;  
    foreach (@uniques){
        if(  ($itemArray[3] eq "$_->[3]") and ($itemArray[4] eq "$_->[4]")
               and ($itemArray[5] eq "$_->[5]" ) and ($itemArray[6] eq "$_->[6]" )
               and ($itemArray[7] eq "$_->[7]" ) and ($itemArray[8] == "$_->[8]" ) ){
            $duplicateFlag = 1;
        }
    }
    if( $duplicateflag == 0){
        $refToAdd = \@itemArray;
        push(@uniques, $refToAdd);
        $output .= "$itemArray[3]" . " \t$itemArray[8]" . " \t$itemArray[5]" . " \t$itemArray[7]\n";
    }
}
print $output

A:

One possibility: Use hashes to determine whether or not an item has been seen before.  A bit simplified from your code:
my %dupHash;
while (my @itemArray = $sth->fetchrow_array() ) {
    my $uniqueItem = itemArray[4];
    if (not exists $dupHash{$uniqueItem}) {
        print "Item $uniqueItem\n";
        $dupHash{$uniqueItem} = \@itemArray;
    }
}

Okay, it's very simplified, but you get the idea.  By using a hash with the values I want to verify are unique, I can avoid the double loop and the O2 algorithm efficiency. ( Dang!  All those years in college finally paid off!). 
You'll probably want to use a more complex hash key by combining all the fields you want to search for dups on.  Maybe something like this:
 # Probably could use join to make it more efficient...
 my $uniqueKay = "$item[3]:$item[4]:$item[5]:$item[6]:$item[7]:$item[8]";
 if (not exists $dupHash{$uniqueKey}) {

The main thing is avoiding looping through all unique items again and again if you can store them in a hash. 

A:

Possibly:
$itemArray[8] == "$_->[8]"

should be:
$itemArray[8] eq "$_->[8]"

to match all the others. 
Another thing that may solve your problem is removing the quote marks around "$_->[8]".  Depends what your data are. 

A:

You are getting all the duplicates because $duplicateflag is undefined at line 13.  Running a syntax test on your script with use strict; use warnings; on produces the following warning:
Global symbol "$duplicateflag" requires explicit package name at t10.pl line 18. 

And if we scrutinize your definition of "that" variable, it says:
my $duplicateFlag = 0;

Which is to say, you have a capital F, which means $duplicateflag is not the same variable as $duplicateFlag.  The check undef == 0 still produces a true value and causes a false positive. 
To avoid problems like this, always run your scripts with
use strict;
use warnings;

