http://qs1969.pair.com?node_id=55300


in reply to Re: Re: namespace craziness
in thread namespace craziness

$x was declared with my, so it is a lexical variable and not in any namespace/package. The package declarations are really a red herring in this code. Compare these similar scripts:
#!/usr/bin/perl -w use strict; use constant FIRST => 25; my $x = FIRST; use constant SECOND => defined $x ? FIRST : 2; print SECOND * $x, "\n"; __END__
#!/usr/bin/perl -w use strict; use constant FIRST => 25; my $x ; BEGIN { $x = FIRST; } use constant SECOND => defined $x ? FIRST : 2; print SECOND * $x, "\n"; __END__