grep returns a list of values for which the code block is true. You're returning $_ if it's a duplicate, which means you'll never return duplicated false values (that is, if @list = (0, 0, "", "", "0", "0", undef, undef) you'll get nothing out of it).