#!/usr/bin/perl use strict; use warnings; my @passwords = qw/ foo bar /; my $count = 0; my $is_valid = 0; while ( $count++ < 3 and not $is_valid ) { print "Passwort eingeben: "; chomp( my $input = ); $is_valid = grep { $input eq $_ } @passwords; } die "Access Denied\n" if not $is_valid; print "Access Granted\n";