On Feb 18, 2008 9:08 PM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Chas. Owens wrote: > > On Feb 18, 2008 7:52 PM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > > snip > >>> eval "use SomeModule" if $ENV{USE_SOMEMODULE}; > >>> > >>> or the sort of tricks that the DBI and other factory classes use. > >> What would be the problem with that? > >> > >> $ perl -le 'eval "use Time::Local"; print for keys %INC' > > snip > > > > Please reflect on the lack of the if statement in your code. > > Sorry, but I still don't get it. > > $ perl -le 'eval "use Time::Local" if 1+1==2; print for keys %INC' snip
That is not a valid example; it is always true. My example used an environmental variable that may or may not be true. The code to detect what dependencies the code has will not find the module if the variable is false, but the code will still be dependent on the module if the environmental variable is set to true later. Another simple example of this is the DBI module. It will not load a given DBD module until a connect is called. Consider my $dbh = DBI->connect(@ENV{qw<DSN USER PASS>); What DBD module does this code require? The problem here is that you cannot be certain all of the modules for a script will be loaded at the start (or any other time for that matter) of a script if the author has decided to load them dynamically. Hopefully the author has documented this well, but no autodetection code can be guaranteed to find it. You might also want to look into the Halting problem* if you don't believe me. If you solve it you can make a lot of money. * http://en.wikipedia.org/wiki/Halting_problem -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/