weltyj has asked for the wisdom of the Perl Monks concerning the following question:
And#this filename is test.pl use strict ; use warnings ; my $a ; require "set_a.pl" print "a is $a\n" ;
When I run test.pl, $a is not initialized. I thought "set_a.pl" would run in the "main" namespace, so the line "$a=1" in set_a.pl would be initializing the variable $a in the main namespace. What did I forget about namespaces, or never learn? :-)#this filename is set_a.pl $a=1 ;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: namespaces and variable initilization with require 'file'
by JavaFan (Canon) on Oct 01, 2008 at 15:11 UTC | |
by weltyj (Novice) on Oct 01, 2008 at 15:29 UTC | |
|
Re: namespaces and variable initilization with require 'file'
by broomduster (Priest) on Oct 01, 2008 at 15:46 UTC | |
|
Re: namespaces and variable initilization with require 'file'
by ikegami (Patriarch) on Oct 01, 2008 at 19:05 UTC | |
by JadeNB (Chaplain) on Oct 01, 2008 at 22:04 UTC | |
by ikegami (Patriarch) on Oct 02, 2008 at 02:02 UTC |