in reply to Re: Flow control / case structure
in thread Flow control / case structure
Another idea, more secure, is to use Perls class heirarchy as the dispatch function. Each action gets translated into a class name and then in an eval used and new()ed. The returned object is then manipulated as so desired. If you prepend a 'safe' root name to the class and the appropriate directory is secure then overall security shouldn't too much of an issue. Also a bit of s///g ing of $action first might be in order.
well anyways those are some of the more unusual ways. :-) I like the class heirarchy the best in some ways cause it neatly modularizes the whole process.#untested sub handle_action { my ($self,$action,$value)=@_; my $obj=eval " use Some::Class::$action; Some::Class::$action->new() "; #eval returns the last value evaluated return $self->raiserror($action,$value,$@) unless $obj->is("Some::Class::Proto"); $obj->exec($value); }
Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)
|
---|