xafwodahs has asked for the wisdom of the Perl Monks concerning the following question:
I have a script that can run with a GUI or not, depending on if the user specifies a -g option.
The GUI is Tk based.
Some of my users don't have Tk installed - they should still be able to run the script in console mode.
First, I tried:
Then I tried:
Any help would be appreciated.
First, I tried:
but the 'use' would complain even of not finding the Tk module (for those without it installed) when the -g option was missing.if ($opt_g) { use Tk; <Tk code> }
Then I tried:
This lets the script work in console mode, but with -g specified, the script fails to bring up the GUI, the script just exits back to the command prompt - no errors or anything.if ($opt_g) { eval "use Tk; 1" or die "Tk not installed. Can't run GUI.\n"; <Tk code> }
Any help would be appreciated.
Back to
Seekers of Perl Wisdom