Hello Hello Monks!
Identified as homework! I am sure I am just not putting my mind into this, but I understand the logic, just not how to get there.
Basically, I have the list of cities, and want the user to enter a city of their choice, LA is there but I wanted it to spit back (LA is not an option).
On top of that be able to take their input (be it one letter or the entire name) and match it to the array and print the results.
I hope this makes some sense, any help or guidance would be greatly appreciated.
my $myCities = "Baltimore:Chicago:Los Angeles:New York:San Diego:";
my @myCities = split(':', $myCities);
print "Please pick one of the following cities by entering any portion
+ of the beginning of the city name:(Baltimore Chicago Los Angeles New
+ York San Diego)\n";
chomp (my $input_city = <STDIN> );
foreach $city (@myCities) {
if ( $input_city == $myCities ) {
#exists;
} else {
print "I'm sorry,we no longer tour LA, please t
+ry again.\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.