in reply to Where to store class configuration settings in a module used by multiple applications

(After more carefully reading the problem, I'm only going to suggest the object member solution.)

You might also consider making the configuration an object member instead of a class member. Then you could have multiple, differently configured Form::Validator objects in existence at the same time. Here's how it would work:

package Form::Validator; sub new { ... $self->{allowed_tags} = []; # initially empty } sub SetConfig { my $self = shift; $self->{allowed_tags] = [ @_ ]; } package WebSite1::FormValidator; my $fv = new Form::Validator(); $fv->SetConfig(qw(a input ...)); ... package WebSite2::FormValidator; my $fv = new Form::Validator(); $fv->SetConfig(qw(...));

You could also make the configuration a constructor parameter.

  • Comment on Re: Where to store class configuration settings in a module used by multiple applications
  • Select or Download Code