If you were to attempt to do this manually, what would be the steps?
- Read the data source into a data structure using the name as an index (see associative arrays in perldoc perldata)
- Ask for partial name chomp(my $name=<STDIN>);
- Perform a case insensitive partial match of the name against the index (see perlre)
- Iterate through the indices of the associative array printing out any that match the test above see perlsyn (foreach) and also the keys operator of associative arrays
Now all you have to do is try and write that in Perl, it'll break the first time and when you get rid of the error messages it won't do what you intended, but that's true of most of our projects,(and anyone who denies it is probably lying) to quote Greg Lemond "It doesn't get easier, you just get faster".
So put up the code you wrote and we'll try and hack it into shape, providing you with a complete solution is not helping you in the longer term.
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
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.