Quotep.s: in letzter Zeit frage ich mich das irgendwie haeufig. Gibt es evtl. manuals / docs zu sowas? Also was alles sauberer style ist und was nicht?
Jup.
http://www.oreilly.de/catalog/perlbpger/
-----------------
Und noch zwei Lösungen. :)
1)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
use strict;
use warnings;
my @passwords = qw/ foo bar /;
my $count = 0;
{
print "Passwort eingeben: ";
chomp( my $input = <STDIN> );
last if grep { $input eq $_ } @passwords;
die "3 mal Falsch eingegeben.\n" if ++$count == 3;
redo;
}
print "Access Granted\n";
2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/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 = <STDIN> );
$is_valid = grep { $input eq $_ } @passwords;
}
die "Access Denied\n" if not $is_valid;
print "Access Granted\n";
\n\n
<!--EDIT|sid burn|1182529671-->
Nicht mehr aktiv. Bei Kontakt: ICQ: 404181669 E-Mail: perl@david-raab.de