in reply to Variable Declaration

$var1 is defined in the scope of the if-blocks. It is not available outside them. Your example here is probably better written as
my $var2 = (cond 1) ? 'a' : 'y';
Downvotes without explanation continue to be the scourge of Perlmonks.

Caution: Contents may have been coded under pressure.