in reply to namespaces and variable initilization with require 'file'

You are quite right; in set_a.pl the variable is initialized in the main name space. However, in test.pl, you have 'my $a', so when you print $a, you are referring to the lexical $a, not the package variable $main::a (which you initialize in set_a.pl). Lexicals and package variable are quite distinct.

And I hope you are using '$a' just for this example - $main::a is special for 'sort'.

  • Comment on Re: namespaces and variable initilization with require 'file'

Replies are listed 'Best First'.
Re^2: namespaces and variable initilization with require 'file'
by weltyj (Novice) on Oct 01, 2008 at 15:29 UTC
    Thanks, that was it. Remembering the nuance of lexicals are too often my nemesis. And yes, the $a was just for the example.