Global variables from a module, while using strict
- From: "Shea Martin" <sam_squirrelnutz@xxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 17:58:35 GMT
|
I have a module which is basically a about 50 global
variables and about 2 methods. Because I am ‘using’ strict, all of
the variables are declared with ‘my’. I in my scripts which use the module, I can’t access
any of the variables, though I can access the sub routines. I looked at Exporter, but there are two problems with the
examples I see. One, they export the globals into the ‘main’
namespace, which I don’t want. I want them to be accessable like this:
Module::myGlobal. The other examples show the importing script explicity
importing every variable. This would be very tedious. Here is an example of what I want: <Sam.pm> #!perl -w use strict; package Sam; my $string = "sam"; sub Str { print "string = $string\n"; } 1; </Sam.pm> <samtest.pl> #!perl -w use strict; use lib "."; use Sam; Sam::Str(); print "Sam::string = $Sam::string\n"; #can't
access $Sam::string here???? exit 0; </samtest.pl> Thanks, ~Shea M. |
- Follow-Ups:
- Re: Global variables from a module, while using strict
- From: Paul Lalli
- Re: Global variables from a module, while using strict
- From: Robert Sedlacek
- Re: Global variables from a module, while using strict
- Prev by Date: Re: Aspell word lists
- Next by Date: Re: Proxy and LWP::UserAgent
- Previous by thread: Aspell word lists
- Next by thread: Re: Global variables from a module, while using strict
- Index(es):
Relevant Pages
|