failmy $saved_pass = 'bd0e9f94ce671b3cdd13081fa5a8b32f9ccd9ebf'; my $eword = 'bd0e9f94ce671b3cdd13081fa5a8b32f9ccd9ebf'; my $passwd_check; $saved_pass eq $eword ? $passwd_check = "good" : $passwd_check = "fail"; print $passwd_check;
goodmy $saved_pass = 'bd0e9f94ce671b3cdd13081fa5a8b32f9ccd9ebf'; my $eword = 'bd0e9f94ce671b3cdd13081fa5a8b32f9ccd9ebf'; my $passwd_check = $saved_pass eq $eword ? "good" : "fail"; print $passwd_check;
Because this operator produces an assignable result, using assignments without parentheses will get you in trouble. For example, this:so what you wrote really means:Really means this:$a % 2 ? $a += 10 : $a += 2Rather than this:(($a % 2) ? ($a += 10) : $a) += 2($a % 2) ? ($a += 10) : ($a += 2)
perlop also says that you can assign to the ternary operator if both arguments between the ? and : are valid lvalues.($saved_pass eq $eword ? $passwd_check = "good" : $passwd_check ) += "fail";
In words: assign "fail" to $passwd_check or $passwd_check :-)if ($saved_pass eq $eword) { $passwd_check = "fail"; }else{ $passwd_check = "fail"; }
In reply to Re: Problem comparing SHA1 string from db, with hashed login password
by Golo
in thread Problem comparing SHA1 string from db, with hashed login password
by hsinclai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |