Mark Hedges wrote:

package Cart;
my $instance;
sub new { return $instance ||= bless {}, $self }
sub is_in_cart { ... }

Under mod_perl, doesn't that mean that if user A is the
first to hit an interpreter and the cart instance is created
for them, then if user B's request is the next to be served
by the mod_perl child, that user B will get user A's cart?

Yes. mod_perl (or any persistent Perl framework) doesn't clear out globals or package variables when the request is done. And in this case, $instance is a package variable.
If that's what you want, then it's a valid way to implement it (usually called 
a Singleton pattern).

--
Michael Peters
Plus Three, LP

Reply via email to