If you
use strict you'll see your first problem.
The basic concept is mistaken - the namespace is supposed to help unrelated modules keep from clashing. Hence a named variable will not work.
You can, however share globals such as $_, and also localized globals.
If you replace $var with $_ in both statements, it'll work.
Morever
$_ = 'gorch';
{
local $_ = 'foo';
printStatement();
}
printStatement();
Will have nice results.
See perlsub for more details on lexical and dynamic scoping.
In general you should always pass an argument to the subroutine for something like this.
-nuffin
zz zZ Z Z #!perl