in reply to **HomeWork** Trying to search an array and match it to a user input
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 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: **HomeWork** Trying to search an array and match it to a user input
by trenchwar (Beadle) on Apr 01, 2008 at 03:04 UTC | |
by kyle (Abbot) on Apr 01, 2008 at 04:27 UTC |