dlapre01 has asked for the wisdom of the Perl Monks concerning the following question:
1.)Prompt the user to type in their name
2.)Take the name from input and compare it to an associative array of names+values
3,)Respond to the name from input according to it's relationship to the data in the array
4.)Print out the key+values ina sentence at the end telling the user their name followed by their role in my family.
#!/usr/local/bin/perl #Family.pl #use strict #use warnings $name=<stdin>; %family['Connie',=>'Mama','Brandy',=>'Sissy','Pete',=>'Dude','Tristan' +,=>'Stinky', 'Sophera',=>'Finky','priscilla',=>'BearDawg']; print"Please type in your name:"/n; $name=<stdin>/n; if((name=<stdin>)!=%family[]) { print"Thank you $name for participating but you are not family./n"; } else-if(($name=<stdin>)==%family[]) { print"Hey $name, thank you for being my %family[]!\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using associative arrays with I/O to interact with Prog. User
by toolic (Bishop) on Dec 01, 2008 at 16:52 UTC | |
|
Re: Using associative arrays with I/O to interact with Prog. User
by moritz (Cardinal) on Dec 01, 2008 at 16:27 UTC | |
by jwkrahn (Abbot) on Dec 01, 2008 at 19:15 UTC | |
|
Re: Using associative arrays with I/O to interact with Prog. User
by cdarke (Prior) on Dec 01, 2008 at 16:54 UTC | |
|
Re: Using associative arrays with I/O to interact with Prog. User
by eighty-one (Curate) on Dec 01, 2008 at 17:11 UTC |