in reply to Coding Perl With Style
Most of the projects I've been on, including the current one what we've done for variables that really need to be accessed from everywhere is first invent a unique namespace for the client. For example, "JacksLumber" Then we create a JacksLumber.pm and in there put all of the global variables we're gonna need as package variables (excused from strict with use vars).
The modules then go under the JacksLumber directory with names like JacksLumber/Tags.pm, JacksLumber/Security.pm, JacksLumber/LnF.pm, etc...
Within the main script "global" values are always accessed by the full package name. For example, $JacksLumber::basedir or $JacksLumber::appname. This has a few effects. First, it doesn't pollute the namespace of the script (like an import might do). Secondly, it makes "global" things stand out (yeah they're lengthy, but you shouldn't be typing them often anyway). Thirdly, we don't have to introduce unnecessary OO complications or encapsulation overkill for things that might not need it. (Although we do have a lot of OO and encap. in other places where it is needed.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Coding Perl With Style
by Fastolfe (Vicar) on Nov 28, 2001 at 01:12 UTC |