pls hlp
well, as you already know (probably), i'm learning perl. i tried to write a password/username-checker, a very simple one.
it's almost working, but it doesn't recognize the username from <STDIN> in my file.
here's the code:
chomp ($user = <STDIN> );
chomp ($pw = <STDIN> );
if ($user ne "") {
open (PW, "pw.txt") or die "Can't open file: $!\n";
@file = <PW>;
close(PW);
} else {
print "insert username and pw end with enter";
}
@users = @file;
@passwords = @file;
foreach (@users) {
s/,.*//g;
}
foreach (@passwords) {
s/.*,//g;
}
#the problem part i suppose
if ($user eq @users) {
if ($pw eq @passwords) {
print "login ok";
} else {
print "login incorrect";
}
} else {
print "no username";
}
i know, i could do the whole stuff with %hashes, but i'd like to try it this way. it's just for getting used to the syntax, not for any application.
i know it's not as complicated as orpheus' problem, so i hope you can help me...
[This message has been edited by alibababa (edited 16 June 2000).]
Orpheus posted this at 17:04 — 16th June 2000.
They have: 568 posts
Joined: Nov 1999
Complicated problems suck. Little problems are awesome. I'd just like to mention a book, Learning Perl volume 2.
If you don't already have it I suggest you buy it. That will teach you everything there is to know about Perl.
Rob Pengelly posted this at 23:14 — 16th June 2000.
They have: 850 posts
Joined: Jul 1999
The problem is with
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
merlin posted this at 07:22 — 21st June 2000.
They have: 410 posts
Joined: Oct 1999
well, thank you robp.
orpheus: i know, i know, my problems are all soluble with reading books. and i do read books (programming perl, o'reilly/perl cookbook, o'reilly), but sometimes i'm just too impatient to read me through the book to solve those little problem, when i know you outthere know the solution. ok, too impatient with myself too...
so i ask you to be my teachers and help me. at this place, i'd like to thank you all for helping me and my impatience...
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.