my $whatever; use subs qw/bar/; map { my $menu = $menubar->cascade( -label => '~' . $_->[0], -menuitems => $_->[1]); $balloon->attach( $menu, -state => 'balloon', -msg => 'foo'); } [ 'Foo', bar ]; sub bar { [ ['command', 'This', -command => sub { $whatever = 'Does this.'}], ['command', 'That', -command => sub { $whatever = 'Does that'}], ] }