At 4:21 pm +0100 07.11.97, Richard Duff wrote: >I am trying to create a CGI using MacPerl that prompts someone for their >password and then verifies it. The archive will contain a list of >passwords in the following format: > >PASS1 >PASS2 >PASS3 >PASS4 > >I already have the open(CHECK, '<passwords.txt') or die "Can't >Verify!!!\n"; command, but I am a little lost after that. Shoud I use >$Line = <INPUT> or $Line = $_ or something else? Can someone help? Something like: sub check_password { my($password) = shift; my($matched) = 0; open(CHECK,'passwords.txt') || die "can't open 'passwords.txt': $!"; while(<CHECK>) { $matched = 1, last if $_ eq $password; } close(CHECK); $matched; } would probably do the trick (God, I hate submitting code in a forum full of Perl gurus; I just *know* someone's going to leap on me and point out a way to do it in half as many lines, a quarter the time, and with an eighth as many bugs. And then my ears will ring with the sardonic laughter of a million contemptuous camels for the rest of the week). Of course MacPerl now ships with 'crypt()' (and "is now officially a munition", quote unquote), so for extra bonus points you can encrypt all the passwords in your file with some secret string, and use 'crypt()' to encode the user-submitted password before testing against the samples read from the file. Doing it this way will not only give you the illicit thrill that you get from using something the White House doesn't want you to have, but it will protect you against the day some fiendishly clever hacker discovers how to retrieve the password file from your Mac. A -- angus@pobox.com http://pobox.com/~angus/ "My loathings are simple: stupidity, [Vladimir Nabokov] oppression, crime, cruelty, soft music." ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch