trenchwar has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl print "Type 'exit' at any time to end this program\n"; while(1) { print "Please enter your first name\n"; chomp ($fname =<STDIN>); exit if $fname eq 'exit'; { last; } print "Please enter your last name\n"; chomp ($lname =<STDIN>); exit if $lname eq 'exit'; { last; } print "Please enter a password\n"; chomp ($password =<STDIN>); exit if $password eq 'exit'; { last; } print "Please enter 'done' or hit enter.\n"; chomp ($ending =<STDIN>); exit if $ending eq 'exit'; if ($ending eq ' ' or 'done') { last; } } my $username = "$lname, $fname"; %name_hash; $name_hash{$username} = $password; print "To search for a user please type in a name and hit enter.\n"; while(<STDIN>) { chomp; exit if $_ eq 'exit'; foreach my $key (keys %name_hash) { if ($key =~ m/$_/i) { print "The username is $username and the passwo +rd is $password, please enter another name to search\n"; } else { print "I'm sorry, there is no one here by that +name, please try another name or type exit to end.\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: No <STDIN> yeilds username and password
by moritz (Cardinal) on Feb 08, 2008 at 22:53 UTC | |
|
Re: No <STDIN> yeilds username and password
by Cody Pendant (Prior) on Feb 09, 2008 at 05:07 UTC | |
by trenchwar (Beadle) on Feb 09, 2008 at 05:37 UTC | |
|
Re: No <STDIN> yeilds username and password
by almut (Canon) on Feb 09, 2008 at 00:08 UTC | |
|
Re: No <STDIN> yeilds username and password
by eric256 (Parson) on Feb 10, 2008 at 21:32 UTC | |
|
Re: No <STDIN> yeilds username and password
by apl (Monsignor) on Feb 09, 2008 at 13:30 UTC | |
by trenchwar (Beadle) on Feb 10, 2008 at 02:00 UTC | |
by apl (Monsignor) on Feb 10, 2008 at 02:18 UTC |