BooYah.pm is only a package if you begin it with:
package BooYah;
Then, all vars in that package can be accessed as $BooYah::var_name.
Of course, you can have more than one package in a script :)
I think what you're asking is "what is the default package?". The answer to that is 'main' or '' by default.
The var would have to be declared globally (no my/local) and explicitly (you are using strict now, aren't you :). BUT, it's a bad idea to rely on vars in main from the package that was required. If you do though, there are two instances I can think of:
# (1)
# Foo.pl - extract
# implicitly
%::crap = (turd => 'yellowy brown',
crap => 'browny black');
# or explicitly
%main::crap = (turd => 'yellowy brown',
crap => 'browny black');
# BooYah.pm - extract
require 'Foo.pl';
# implicitly
print $::crap{turd};
# or, explicitly
print $main::crap{turd};
# (2) - give Foo.pl a namespace
# Foo.pl - extract
package Foo;
%Foo::crap = (turd => 'yellowy brown',
crap => 'browny black');
# BooYah.pm - extract
require 'Foo.pl';
print $Foo::crap{turd};
Although I'm a little worried about your question. Shouldn't you be requiring the module from the script and not requiring the script from the module?!?!
Do some research on namespaces, or read perlmod documentation.
cLive ;-) |