The problem was solved by others before I got a crack at it but I couldn't resist explaining. It's not often I see something on here I could solve.
You've got a classic beginner problem. This is scoping. Since you declared the variables (using "my") inside the if statement it only exists inside the if statement. So as soon as you leave your if statement you no longer have a value in $var1 so basically you assign nothing to $var2.
Get Learning Perl and a big package of little yellow sticky notes to flag your favorite pages.
gj