tommyw has asked for the wisdom of the Perl Monks concerning the following question:
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?)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Segmentation fault at exit on Solaris 5.6.1 if require Tk instead of use
by broquaint (Abbot) on Jun 12, 2003 at 09:44 UTC | |
by tommyw (Hermit) on Jun 13, 2003 at 10:02 UTC | |
Re: Segmentation fault at exit on Solaris 5.6.1 if require Tk instead of use
by PodMaster (Abbot) on Jun 12, 2003 at 09:45 UTC | |
by tommyw (Hermit) on Jun 13, 2003 at 10:06 UTC | |
by PodMaster (Abbot) on Jun 13, 2003 at 10:20 UTC | |
by tommyw (Hermit) on Jun 13, 2003 at 11:19 UTC |