One more quick question....hopefully.
I think I figured out the first part (trying to say LA is not a choice)
But I want anything else in the array to be a successful choice and then exit the loop. I have tried a few things, but can't seem to get it to exit.
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:(@myCities)\n";
while ( my $input_city = <STDIN> ){
foreach ($input_city) {
if ($input_city =~ m/^L/i ) {
print "We no longer tour LA, please try again!\n";
}
if ( $input_city eq $myCities ){ ### here is where im lost##
print "Found\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.