trenchwar++ for identifying as homework.
You should use eq to test for string equality (use == only when comparing numbers). See perlop for other string and numeric comparison operators.
If you want to match partial city names instead of whole city names, you might be interested in substr and length or perhaps index. If you want to be case insensitive as well, lc could help.
If you want LA to be a special case, check for it before you check for anything else.
if ( $input_city eq 'Los Angeles' ) { # handle the City of Angels } else { # handle cities of non-angels }
In reply to Re: **HomeWork** Trying to search an array and match it to a user input
by kyle
in thread **HomeWork** Trying to search an array and match it to a user input
by trenchwar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |