in reply to If doesn't work

If $value1 and $value2 are not numbers, you will need to use eq instead of ==.
if($value1 eq $value2) { ... } else { ... }
A recent discussion on the topic of == and eq can be found at Mysterious the ways: == and eq.

ctweten beat me to replying, so this post is a kind of useless duplicate.