One additional clue to the compile-time/run-time distinction is if you turn on -w in the she-bang line (or 'use warnings').
You get a warning from inside test()
Use of uninitialized value in concatenation (.) or string at ./script.pl line 13
So Perl knows about $var, but it is undefined - so the '= 1' part hasn't happened when we are in test()...
+++++++++++++++++
leriksen - Chief Cat Herder
/#!/usr/bin/perl
use warnings;use strict;use brain;