We need to see less code. Focus down on the two lines that are causing your trouble and just enough other lines so that we can reproduce it. Your sample code has far too many unknown entities. Try adding use strict; use warnings; and if it doesn't compile clean (appart from your error) then clean it up.

Are any of the ->put lines relevant to the problem?

I'd guess you are after something like the following (but I can't tell from your code):

use strict; use warnings; use Tk; my @unpaidbills = (['Fred', 1.27], ['Joe', 3.46], ['Francis', 2.22], [ +'Joanne', 5.23]); my @checkboxes; my $main = new MainWindow; foreach my $bill (@unpaidbills) { my $state = 0; # Note we get a new $state each time through my $button = $main->Checkbutton ( -text => "$bill->[0]: $bill->[1]", -variable => \$state ); $button->pack (); $checkboxes[@checkboxes] = [$button, $bill, \$state]; } $main->Button(-text=>'Submit', -command=> [\&doSubmit, \@checkboxes])- +>pack (); MainLoop (); sub doSubmit { my ($checkboxes) = @_; for my $entry (@$checkboxes) { my ($button, $bill, $state) = @$entry; if ($$state) { print "$bill->[0] paid \$$bill->[1]\n"; } else { print "\$$bill->[1] not paid for $bill->[0]\n"; } } }

DWIM is Perl's answer to Gödel

In reply to Re: Array of TK::Checkbuttons not acting appropriately by GrandFather
in thread Array of TK::Checkbuttons not acting appropriately by mikasue

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.