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

A Worry-Wart's Worry

Some Perl/Tk scripts exit in an unclean manner when run on my netbook.

They are small sample scripts from "Learning Perl/Tk", first edition; and when they exit, a report of a segmentation fault is returned.

There are no other side-effects, and it's all probably harmless, or is it? I've noticed that the text of this book is riddled with errors; has the author missed something vital? Checking with -w and use strict don't throw up any compile-time errors.

Perl here is v5.8.8 and the OS is Linpus Linux (a version of FC8 adapted by Acer).

Replies are listed 'Best First'.
Re: Perl/Tk exit trouble?
by zentara (Cardinal) on Jan 09, 2010 at 11:34 UTC
    The book of which you complain was getting old, 10 years ago. It was the first Perl/Tk book written back in the heady days of the first Perl5's.... in other word it is obsolete and nobody cares. The book that is normally recommended by those who actually read the books, is Mastering Perl/Tk by the late Nick Ing Simmons.

    Mr. Simmon's passing brings up another point about Perl/Tk, no one is actively pursuing improving the Perl/Tk port of the TCL/Tk..... Slaven Reszic is maintaining the latest Tk version, but it is starting to split off.... i think the Window's ActiveState ( which came with Tk built-in ) is now shipping their own spinoff called Tkx.

    But it really dosn't matter.... if you want the latest, best, and most actively developed.... use Gtk2 or Wx ..... Tk still works, but it is falling behind Gtk2 fast like an old man chasing an 18 year old. :-) See Gtk2 free tutorial

    If you can post a small code example, of code that has this exit problem, and state your Tk version, someone may know an answer..... install the latest version of Tk from cpan too.... it always pays to have the latest libs


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku

      Thank you,

      The Perl-Tk version is 804.027 and here is one of the scripts which misbehaves; as you can see, it's an exercise answer from one of the earlier chapters -

      #!/usr/bin/perl -w # 123ex1 - Combination of Entry and Label widgets. # Another segmentation fault; that's interesting. # # Setting the Label width forces the widget to scroll, # otherwise it will expand the window x-wise to # accomodate the extra text. Try -wraplength also. use Tk; use strict; my $message; my $mw = MainWindow->new; $mw->title("Label following Entry"); $mw->Label(-textvariable => \$message, -width => 40) ->pack(-side => 'bottom', -fill => 'x',); my $e = $mw->Entry(-textvariable => \$message) ->pack(-expand => 1, -fill => 'x'); MainLoop;

      I agree, the book is well out of date, but it was a cheap 'pre-loved' deal on Amazon. I've already give up on the book as a tutorial. Thanks for the advice about GTk2 - I may just follow that up.

        The Perl-Tk version is 804.027

        ... no that is an old version, now it it 804.028

        Many bug fixes have been incorporated in the move from .027 to .028

        See Cpan's Tk.... it's easy to install


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku

        No segmentation fault on my system (Slackware with Perl 5.10.0).

        the trouble may be with Tk, Perl or even the OS.