[EMAIL PROTECTED] wrote:
> How can you get perl to not check for modules that are loaded
> conditionaly? In the example below perl would still error on the Tk
> module(s) if they are not installed. I'm basically coding to support
> both a GUI and command line mode, eventually across a couple of
> platforms.
>
>
> ~snip~
>
> $runmode eq "cmdline";
>
> if ($runmode eq "GUI") {
> use Tk;
> use Tk::HList;
> use Tk::Text;
>
> }
> use DBI;
> use Term::ReadKey;
> use Term::ReadLine;
>
> ~snip~
There are about 3 ways to handle it.
1) use 'require' and maybe 'import' instead of use to delay loading.
my $is_GUI = 1;
...
require Tk;
import Tk; # if needed
2) use 5.8 if conditional:
my $is_GUI = 1;
...
use if $is_GUI, 'Tk';
3) use an eval on the use to delay loading:
my $is_GUI = 1;
BEGIN { eval "use Tk" if $is_GUI; }
_______________________________________________
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs