in reply to Re: How to a construct objects with variables as class names?
in thread How to a construct objects with variables as class names?

Good suggestion, though I'm actually checking for that in the sub that gets the classname from the database. If the query returns nothing, it errors out. Defining the names in the database is at least as reliable as putting them in an array, I think. Since I use all of the widgets at the top, that should catch any potential mistakes in the db.

I'm curious to know if there is a way to get around useing them though -- I would ideally like to be able to add widgets by simply:

1) add the class module to the directory
2) add the class name to the database

The above sub resides in a module running on mod_perl, so every time I change it, I have to stop and restart the http server, which I'd rather not have to do. Of course, I realize there are some stability problems that could arise when doing this sort of thing.

joecamel

Replies are listed 'Best First'.
Re: Re: Re: How to a construct objects with variables as class names?
by MeowChow (Vicar) on Feb 14, 2001 at 12:48 UTC
    Sure, this is secure so long as the table you're checking the values against is comprised of data that only you (not your users) can manipulate, and it sounds like this is what you're doing.

    Regarding your second question, you may want to have a look at Related question: loading modules at run time. You will also want to do something like:

    eval "require $pkg";
    because of the differences in the way require EXPR works from require BAREWORD.

       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print
      Awesome, I eliminated the uses from my module, and added

      eval "require $fullClass";

      to the subroutine -- it worked perfectly.

      Thanks, MeowChow and Adam, for your help.