my $var = 2; sub x{ print $var; } x(); # prints 2 $var = 3; x(); # prints 3