Multiple Conditions Perl if Statement

Hello,
I'm trying to put together a script that involves pulling data from a config file. I'm attempting to write an if statement to validate one of the pieces of data from the config file, but I think I'm fat fingering it somehow.

$config{VALUE} is being pulled from a config file but can only be one of three options. The hope is to write an if statement to ensure that $config{VALUE} is one of those 3 options.

This is what I'm attempting to use, but if intentionally supply an invalid option, it doesn't catch.

if (($config{VALUE} ne "A") || ($config{VALUE} ne "B") || ($config{VALUE} ne "C"))
{
    die "Missing or Invalid VALUE.";
}

Any help would be appreciated.

Thanks!

HI,

Hope the below thread helps:

Hi Filter,
Thanks for the response. The way I'm pulling from the config file is not by line number but instead by the value name.

Example Config File:
VALUE=A
IPADDR=10.0.0.1

Which eventually would translate into variables $config{VALUE} and $config{IPADDR}

I also tried restructuring the if statement like in your example but no dice:

if ($config{VALUE} ne "A" || $config{VALUE} ne "B" || $config{VALUE} ne "C")
{
die "Invalid VALUE";
}

It's just the boolean logic. Change || to && and think about it.
More idiomatic:

die "..."  if $config{VALUE} !~ /[ABC]/; # But I think you really need /A|B|C/

Thanks for the help