byoungvt has asked for the wisdom of the Perl Monks concerning the following question:

Dude Monks,

I am having a little problem, I want to be able to have a script which has both a tk gui and a text interface. However if I use "use" to load Tk perl chokes when it tries to load/compile the module on machines where it is not installed; I have since switched to require (not really knowing what it does), and it kinda works is require just like an #include???? Is this the proper solution??? Or do ya' all monks have something proper and elegant????

BJY
sub buildgui { (my $fname)=@_; require Tk; require Tk::FileSelect; my $mw=MainWindow->new; $mw->title("DNA to Protein"); my $LoadDialog = $mw->FileSelect(); $LoadDialog->configure();

Edit by myocom (formatting, code tags)

Replies are listed 'Best First'.
(ichi) Re: use/require TK, What up with that??
by ichimunki (Priest) on Mar 15, 2002 at 22:54 UTC
    See this node for more information about use and require. If you want a Tk-able script to run even when Tk is not installed you need to go with require. But this is not without some hassles, as noted in the referenced node.