I've done this several times for several different reasons. Your main issue is that the use statement is interpreted as soon as the ; is hit. What I've done has been a variation of
if ( $need_library ) { eval "use THE_LIBRARY_IN_QUESTION;"; die $@ if ( $@ ); }
or something close to that. I think I once populated a list with needed libraries and looped through the list to load (use) them.
-- doug
In reply to Re: Conditional including of a module
by doug
in thread Conditional including of a module
by edwardo_
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |