freelanceprogrammers.org Forum Index » Perl

Extracting Users


View user's profile Post To page top
jpfuncrochet Posted: Sun Jun 27, 2004 1:42 am


Joined: 27 Jun 2004

Posts: 3
Extracting Users
Hi Everyone,
I hope someone can help.

I am trying to extract all users from a .htpasswd file who is in an
array and
put them in a new file.

Here is the code I have below that I am using to try to do this.
What am I
doing wrong? All it does is match the last one in the array.

#this first section counts how many have the :7000 in the line.
open(MEMBERS,"$members")||print qq(Cannot print because: $!);
@memberlines=<MEMBERS>;
close(MEMBERS);

$count=0;
foreach $member(@memberlines) {
if($member =~/:7000/) {
$count++;
}
}

print qq( $! Monthly Member Count: $count<p>);

#This next section is supposed to take the same array and extract
them. This
part works.
foreach $mem(@memberlines) {
if($mem =~/:7000/) {
push(@memberss,$mem);
}
}

# this section just takes the username out to work with. Works fine.
foreach $mm(@memberss) {
@marray=split(/:/,$mm);
push(@accts,$marray[0]);
}

open(PASS,"$passfile")||print qq(Cannot open passfile because: $!);
@passlines=<PASS>;
close(PASS);

#this section is supposed to take the names in the @accts array and
matches each
one to the password file names. when it finds one that matches it, I
want to
add it to a new array and then put that new array into a new
username and
password file. This next section is what is giving me grief. Can you
help?
#this is the contents of the password file I want to take from.
foreach $p(@passlines) {
($us, $ps)=split(/:/,$p);

#this is the @accts array
foreach $m(@accts){
if($us eq $m) {
push(@pas,$p);
}
} }



print qq(<br><hr>);

# after I know this works, then I will take the usernames and
passwords and add
them to a new password file. Right now I am just printing them to
the screen.
As you can see, I am not done with the code.

foreach $pp(@pas){
print qq($pp<br>);
}
exit;
1;

Julie A. Bolduc jbolduc@j...
JPF Crochet Club
Free Patterns And More!
http://www.jpfun.com
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help