#!/usr/bin/perl $ADMIN_EMAIL = cs476 ; $MAX_TRIALS = 3; init_words(); print "what is your name? "; $name = ; chomp($name); print "Hello, $name!\n"; print "What is the secret word? "; chomp ($guess = ); while (1) { if ($words{$name} eq $guess) { print "Welcome $name\n"; last; } elsif (++$trial < $MAX_TRIALS){ print "Wrong, try again. What is the secret word? "; chomp ($guess = ); } else { print "$name, you tried $MAX_TRIALS times, mail sent to admin.\n"; open (MAIL, "|Mail -s \"login violation\" $ADMIN_EMAIL"); print MAIL "bad news: $name guessed $MAX_TRIALS times\n"; close MAIL; last; } } sub init_words { $filename = ; open (WORDSLIST, $filename)|| die "can't open $filename: $!"; while ($name = ) { chomp ($name); $word = ; chomp ($word); $words{$name} = $word; } close WORDSLIST; }