my %already_selected; ...... unless ( $already_selected{$find} ) { $already_selected{$find}++; #this number is selecting first time .... }