The short answer is that you must remove the newline from $userPassword.

Code

chomp $userpassword;

I can suggest many improvements to your code.

Start every perl program with

Code

use strict; use warnings;

This will require you declare all your variables with "my".

Use grep to search the list @Passwords.

Do not use they syntax &passwordChecker unless it is really needed. Use passwordChecker().

Use else rather than elsif for access denied. (There is no other possibility)

It would be even better to use modules. Some prompt modules even have an option not to echo the password. Use the function 'any' from the module List::MoreUtils rather than grep. It is slightly faster, and the intent is clearer. Good Luck, Bill