Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening several files at same time..

Status
Not open for further replies.

perlone

Programmer
Joined
May 20, 2001
Messages
438
Location
US
Hello,

I have a form and when the user submit the form, I need to make sure that email/username is not taken. All my user's directory is like this:

| | |
ROOT USERS USER-EMAILS

Each User-Emails contains the following files.
user.txt - inludes username
pass.txt - includes password
gender.txt - includes gender.

I need to make sure when the user submit the form, that the email/username is not taken. For the email part, i did the following:

if (-e "$basedir/users/$FORM{'email'}") {
print "That email is already taken!";
exit;
}else{
&name_check;
}

And for the username check, i need to open all the directories in the $root/cgi-bin/users and open all the files called user.txt and to make sure if it's taken or not. Now it seems a little silly to do all these stuff just to make sure that the username is taken or not, but I don't know any other way to do it. Any clue? No?
 
Would something like this help?

my $fname;
while(<$root/cgi-bin/users/*/user.txt>){
[tab]# process each user.txt file here
[tab]$fname=$_;
[tab]open(F,$fname) || die;
[tab]while(<F>){
[tab][tab]# read each line of the file
[tab]}
[tab]close(F);
} Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Wouldn't it be more efficient to (also) keep all the usernames in a single file that you could read? It's one extra step when you add a user, since you have to open the usernames file and append the new one to it, but that would still be faster than opening ALL the username files to check for it.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top