
CuzDesign
Deleted
Jun 6, 2000, 2:26 AM
Post #1 of 2
(293 views)
|
|
Testing Database file with and only printing if found
|
Can't Post
|
|
Hello, I have a question here and I cannot seem to figure it out for the life of me. Here is what I am trying to do. I want to test the contents of a database file it is a username and password file. I know hoe to check if each there is a match but what happens is this. Say tehre are 5 records in the databse like so. name:password name:password Now I want to go through all the entries and if the proper username and password was entered print one thing if not print another but what is happenning is that it is printing the nomatch over and over and over again. How can I get this to check the database then if finds a match print one thins only once, but say if there are no matches print another only after it has tested the complete database file for a match then print. Here is what I am using now. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> open (DATA,"<passme.dat") or die "Couldn't open passme.dat $!\n"; while (<DATA> ){ chomp; @list = split(/:/,$_); if (($user eq $list[0]) && (crypt($password, $salt) eq $list[1])) { print "ok\n"; }else{ &error; } } </pre><HR></BLOCKQUOTE> Any help here would be greatly appreciated. Thank you, Ray
|