If, prior to printing out @wrongPasswords, you check the number of elements in the array (print scalar @wrongPasswords) you will find there are 9 - the 5 empty ones that you originally created, plus the 4 wrong guesses that were subsequently pushed onto the array.