I cannot get the kinks worked out of the following program. I have been reading three different reference books plus loads of online tutorials and I learn best by doing. So I decided to use my knew knowledge of associative arrays to write a program that would
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";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.