This Perl code is part of the variable declaration at the beginning of a piece of code. What does it mean?
my $EXPLICIT_YEAR = $ALL_PAGES ? 0 : ($store{year} || $current_year);
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.
It’s equivalent to this:
The
$conditional ? $true : $falseportion is a ternary if.The
$store{year} || $current_yearportion uses the fact that the || operator returns the first value that evaluates to true, allowing $current_year to be used if $store{year} is “false” (zero, empty string, etc.)