#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Pane; my @a=qw/one two three four five six seven eight nine ten/; my $mw = MainWindow->new; $mw->geometry('200x200'); my $f = $mw->Scrolled("Frame",-borderwidth => 3, -relief => 'groove',-height=>20) ->pack(-expand=> 1, -fill=>'both'); foreach my $i (0 .. 19){ # this should be foreach my $i (@a), but it's your code :-) print "$i\n"; my $c = $f->Checkbutton(-text=>$a[$i],-command=>[ \&fun, $a[$i] ] )->pack(); $i++; } MainLoop; sub fun{ print "@_\n"; }