I have a statement
$set eq "Y" ? $set = "N" : $set = "Y";
But no matter what it always sets to "N"
# Toggle setting
if ($set eq "Y")
{
$set = "N";
}
else
{
$set = "Y";
}
Why doesn’t the one liner seem to work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Due to precedence rules, perl is not parsing your statement as you think:
So as you see, in both conditions, the final result is the
$setscalar which then gets set toY.You can fix it with a few parens:
But why repeat the assignment: