in reply to Re: Use with variable
in thread Use with variable
It's easy to think of applications for this technique. Any sort of "plug-in" or "load-on-request" situation. Or "drivers", for instance. Ever use DBI? Notice how you only have to "use DBI;" and then the appropriate "DBD::*" module is loaded according to the datasource in your DBI->connect() call? That magic is done by dynamically loading a module that is contained in, yes, you guessed it, a variable! Actually, the eval method is used there:
# --- load the code my $driver_class = "DBD::$driver"; eval qq{package # hide from PAUSE DBI::_firesafe; # just in case require $driver_class; # load the driver }; if ($@) { #....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Use with variable
by radiantmatrix (Parson) on Sep 08, 2004 at 15:34 UTC |