Here is a test script. Run it with a -g as the first parameter.
On a machine without Tk, it will correctly die.
On a machine with Tk, it *should* bring up a simple Tk window, but it exits instead. If I replace the 'require' and 'import' with the 'use', then it works.
if ($ARGV[0] =~ /-g/) {
# do gui
die "You need Tk." unless (eval("require Tk;"));
#use Tk;
require Tk;
Tk->import;
$mw = MainWindow->new;
$mw->Button(-text=>"EXIT",
-command=>sub{exit})->pack(-side=>"bottom",
-fill=>"both");
MainLoop;
print "gui done.\n";
} else {
# do non-gui
print "non-gui stuff\n";
}