theguvnor has asked for the wisdom of the Perl Monks concerning the following question:
I have a module that saves some data to a site-specific directory; the module will be used by several sites hosted on the same physical server. Therefore I have a method that sets the directory; but I made it a class method, so that I could set it once like
use MyModule; MyModule->save_dir('/siteX/some/dir');
and then initialize a bunch of instances of the MyModule object.
Then a sudden fear strikes me - will a script using MyModule running at siteX and setting the directory accordingly, interfere with the same script that will be called from siteY (and therefore setting the directory property to another directory)? What I mean is, will it be safe for two scripts identical except running on different virtual servers and setting a different directory variable, interfere with each other? My thought was that I'd be OK but like I said, a sudden panic attack struck me ;)
Here are the class data methods:
# class data and class method accessors { my $ERROR = ''; my $POST_DIR = ''; sub error { my $self = shift; my $class = ref($self) || $self; # get class of object +if called as instance method if (@_) { $ERROR = $class . ' error: ' . shift; } return $ERROR; } sub post_dir { my $self = shift; $POST_DIR = shift if @_; return $POST_DIR; } }
I hope what I'm asking is clear; let me know if not.
...Guv
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OO module question re: class data vs. instance data
by japhy (Canon) on Feb 06, 2002 at 02:45 UTC | |
by theguvnor (Chaplain) on Feb 06, 2002 at 04:15 UTC | |
|
Re: OO module question re: class data vs. instance data
by mstone (Deacon) on Feb 06, 2002 at 22:47 UTC | |
|
Re: OO module question re: class data vs. instance data
by Fastolfe (Vicar) on Feb 06, 2002 at 22:15 UTC |