http://qs1969.pair.com?node_id=123148

tretin has asked for the wisdom of the Perl Monks concerning the following question:

Monks,
I have once again come to harken at your gates for an answer to one of my many problems.

I just finished going through both the file input/output and looping tutorials and decided I'd try to write up a script that incorporated both aspects. I'm trying to create a simple login script, that prompts the user for his/her name and then the password, then runs a check to see if the names/passwords match; if they do then a file is opened and the lines displayed. I've gotten it to recognize correct/incorrect password/username identification, but I'm having trouble with the opening of the file. If the user/pass check is successfull the file does not open, and if it is unsuccessful it does not open. Maybe it's just too late for me to be attempting to script but here is what I've gotten thus far:
#!/usr/bin/perl -w my $cusr; $cusr=bob; my $cpword; $cpword=pass; print "What is your username? "; $usr=<>; chomp($usr); if($usr==$cusr){ print "One moment please...\n "; print "Please enter your password:\n "; $pword=<>; chomp($pword); if($pword==$cpword){ print "One moment please...\n "; print "Authentication Complete!\n "; } } if($pword==$cpword){ open (FILE, "memberlist.txt"); while(<FILE>){ push @lines,$_; close FILE; } } else{ print "ERROR: username or password incorrect, please try again\n " +; }
and specifically (or at least I'd assume specifically)where the problem lies, in the following lines :
if($pword==$cpword){ open (FILE, "memberlist.txt"); while(<FILE>){ push @lines,$_; close FILE; } }
That's it... and I can't seem to find the problem. Any help at all is immensly appreciated, and I ask that you please bare with me, as I am very very new to the world of Perl (and of programming on the whole) so if there's an obvious problem here please don't laugh too hard at my incompetence :).

Thank you again for your time monks, and again I appreciate any help you can give.

just my 5 cents (ran out of pennies!)

Edit: chipmunk 2001-11-04