wouldnt you use if ($$2) ? I thought $$ meant to fail if $2 didnt exist. So if you want to test for 0 (i.e false) as well

if ($$2) {
your code here test for 0 as well
}
else {
it didnt exist
}