Assuming that Tk is available, this produces a simple exit button. On my mandrake 9.1 box at home (perl 5.8.0) this works fine, and silently. On my solaris box at work (perl 5.6.1), it produces a segmentation fault at exit. However, if I change to "use" instead:#! /usr/bin/perl -w use strict; eval { require Tk; import Tk; }; die "Can't load Tk" if $@; MainWindow->new->Button(-text => "Cancel", -command => sub {exit 1} )->pack(-side => 'left', -expand => 1); Tk::MainLoop();
Then it behaves the same on both machines, generates the text:#! /usr/bin/perl -w use strict; use Tk; MainWindow->new->Button(-text => "Cancel", -command => sub {exit 1} )->pack(-side => 'left', -expand => 1); Tk::MainLoop();
on stderr, and no segmentation fault occurs. Why? What's different? What am I doing wrong? (Hopefully, if I can make require and import behave like use, I can also get around the segmentation fault.)Callback called exit. Callback called exit.
--
Tommy
Too stupid to live.
Too stubborn to die.
edited: Thu Jun 12 12:13:52 2003 by jeffa - title change (was: Use != Require & Import?)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |