I don't know if Tkx is the same (I suspect it would be), but in Perl::Tk there is the "callback" (see Tk::callbacks), an array reference that encapsulates a function reference and a set of aguments:
c:\@Work\Perl\monks>perl -wMstrict -le
"use constant Y => 'bar';
;;
my @callbacks;
;;
my $z = 9;
;;
for (my $x = 1; $x < 4; $x++) {
push @callbacks, [ \&foo, $x, Y, $z-- ];
}
;;
$z = 'zero';
;;
$_->[0]->(@$_[ 1 .. $#$_ ]) for @callbacks;
;;
sub foo { print qq{@_}; }
"
1 bar 9
2 bar 8
3 bar 7
(Don't worry about the messy
$_->[0]->(@$_[ 1 .. $#$_ ]) stuff in the example; that's all taken care of under the hood in
Tk and is only intended to illustrate the principle.)
Update: Changed example code to include $z variable.
Give a man a fish: <%-{-{-{-<