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

Hello all, I am trying to make a Hlist after a selection event from another Hlist. The code crashes with: "Tk::Error: Failed to AUTOLOAD 'Tk::Widget::Hlist'" after I click on 'Text 1'. This is the (stripped) code:
use strict; use Tk; use Tk::HList; our $mw; my ($g2list, $e); $mw = MainWindow -> new; $g2list = $mw -> HList (browsecmd => \&check_uitgever, -columns => 1) +-> pack; $e = $g2list -> addchild (''); $g2list -> itemCreate ($e, 0, -text => 'Text 1'); MainLoop; exit; #================================================== # # Subroutines # sub check_uitgever { my $uglist = $mw -> Hlist (-columns => 1) -> pack; }

What do I do wrong?

Replies are listed 'Best First'.
Re: Use Hlist from selection event
by jdporter (Paladin) on Oct 19, 2007 at 14:29 UTC

    The error message is telling you exactly what's wrong. Why are you ignoring it? (Hint: Perl is case sensitive. You already knew that.)

    A word spoken in Mind will reach its own level, in the objective world, by its own weight
      Thanks. Based on your comment, I finally located the error, which I have overlooked for days. Yes, I well know Perl is case sensitive. Funny how you can repeatedly go over some code without realizing what you think you see is not what you see...
Re: Use Hlist from selection event
by strat (Canon) on Oct 20, 2007 at 10:20 UTC
    >> $g2list = $mw -> HList (browsecmd => \&check_uitgever, -columns => 1)

    needs a - before browsecmd:

    $g2list = $mw -> HList( -browsecmd => \&check_uitgever, -columns => 1 )

    Older Tk-Versions don't require the -, but newer ones raise an error if the - is missing.

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"