Link to home
Start Free TrialLog in
Avatar of mmcw
mmcw

asked on

Control over input

Hello,

I want to do the following:

$country = "netherlands, nederland, holland, nl";

if ($test = "one of the values of $country) {
      $x = 1
}

One of the values can be netherlands or nederland or holland or nl.
$test is an input out of a form.

It must be case insensitive!

So if the input $ test = "Netherlands" it also must work

greeting Michel
ASKER CERTIFIED SOLUTION
Avatar of stam061398
stam061398

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dmethvin
dmethvin

This is really hash territory:

my %country = map { ($_, 1) } qw(netherlands nederland holland nl);

$test = "Nl";

my $Found = $country(lc($test)) || 0;
print $Found,"\n";


Whoops, let's try that again:

my %country = map { ($_, 1) } qw(netherlands nederland holland nl);

$test = "Nl";

my $Found = $country{lc($test)} || 0;
print $Found,"\n";