in reply to OO Design Question
I don't really like using eval much. There's probably a better way to get a hard ref to the train function, but I don't see it right now.new { my ($class, $conf_file) = @_; my $opts = read_conf( $conf_file ); $opts->{model_trainer} = eval sprintf q{ require %s; \&%s::train }, ($opts->{model}) x 2; # ... validation ... bless $opts, $class; } sub train { my $self = shift; my $data = voodoo( shift ); $self->{model_trainer}->( $self, $data ); }
|
|---|