Wiggins has asked for the wisdom of the Perl Monks concerning the following question:
"Perl does not patrol private/public borders within its modules--...." Programming Perl 2nd Ed. Pg 287.
This code is a minimalist example of my problem. The global data in 'main' is coming up undefined when read from the package.
Here is the pit.pmuse strict; require "pit.pm"; ## also use or require w/o quotes my $Email="abc\@example.com"; print "1) $Email\n"; pit::printIT(); print "1) $Email\n"; print "1) done\n"; #use pit; ## doesn't work here either
Running gives:package pit; sub printIT { my $xyzzy = $main::Email; print "2) #xyzzy\n"; } 1;
What do I have to do in main to let other packages read my $main::Email variables?wf13[~]>perl testGlobal.pl 1) abc@example.com 2) 1) abc@example.com 1) done
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: My globals are visable; but undef'ed
by Joost (Canon) on Jul 31, 2008 at 18:40 UTC | |
by BrowserUk (Patriarch) on Jul 31, 2008 at 22:15 UTC | |
by tilly (Archbishop) on Jul 31, 2008 at 19:26 UTC | |
by Joost (Canon) on Jul 31, 2008 at 20:05 UTC | |
by tilly (Archbishop) on Jul 31, 2008 at 21:30 UTC | |
by Joost (Canon) on Jul 31, 2008 at 21:37 UTC | |
| |
|
Re: My globals are visable; but undef'ed
by tilly (Archbishop) on Jul 31, 2008 at 19:33 UTC | |
|
Re: My globals are visable; but undef'ed
by betterworld (Curate) on Jul 31, 2008 at 18:53 UTC | |
by massa (Hermit) on Jul 31, 2008 at 20:28 UTC | |
by chromatic (Archbishop) on Aug 01, 2008 at 05:38 UTC | |
|
Re: My globals are visable; but undef'ed
by Wiggins (Hermit) on Aug 06, 2008 at 19:06 UTC |