Hey all,
Im trying to figure out how to do an if statement to match one of three vaules.
(START CODE)
my $value1 = 5
my $value2 = 6
my $value3 = 7
#Lost but Ill give an example
If ($random == $value1|$value2|$value3) #This didnt work. It always matched
If ($random == $value1 .. $value3) #This didnt work either.
(END CODE)
so any tips on how to acheive what I am trying would be nice.
what I have now is
(START CODE)
if ($random == $value1)
{
}
elsif ($random == $value2)
{
}
elsif ($random == $value3)
{
}
(END CODE)
This will work but I wanted to put a bunch of code the same code in the block if the condition was try and dindt want to include the code three times.
Thanks Rid
Im trying to figure out how to do an if statement to match one of three vaules.
(START CODE)
my $value1 = 5
my $value2 = 6
my $value3 = 7
#Lost but Ill give an example
If ($random == $value1|$value2|$value3) #This didnt work. It always matched
If ($random == $value1 .. $value3) #This didnt work either.
(END CODE)
so any tips on how to acheive what I am trying would be nice.
what I have now is
(START CODE)
if ($random == $value1)
{
}
elsif ($random == $value2)
{
}
elsif ($random == $value3)
{
}
(END CODE)
This will work but I wanted to put a bunch of code the same code in the block if the condition was try and dindt want to include the code three times.
Thanks Rid