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:
Thank you again for your time monks, and again I appreciate any help you can give.
just my 5 cents (ran out of pennies!)
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:
and specifically (or at least I'd assume specifically)where the problem lies, in the following lines :#!/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 " +; }
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 :).if($pword==$cpword){ open (FILE, "memberlist.txt"); while(<FILE>){ push @lines,$_; close FILE; } }
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Variable/if question...
by mkmcconn (Chaplain) on Nov 04, 2001 at 12:24 UTC | |
Re: Variable/if question...
by Indomitus (Scribe) on Nov 04, 2001 at 12:17 UTC | |
Re: Variable/if question...
by Amoe (Friar) on Nov 04, 2001 at 16:52 UTC | |
Re: Variable/if question...
by danger (Priest) on Nov 05, 2001 at 15:05 UTC | |
by tretin (Friar) on Nov 07, 2001 at 08:23 UTC |
Back to
Seekers of Perl Wisdom