use strict; use warnings; my $x = 1; sub foo { print("[$x]\n"); } BEGIN { foo(); } # Prints "[]" and gives an undefined warning.