my $cmds = $tl->Frame; $cmds->pack; if (defined $idx) { # Existing activity - OK Apply Delete Cancel $cmds->Button(-text => 'OK', -command => sub {&edit_entry($idx,$legentry);$tl->destroy;}) ->pack(-side => 'left'); $cmds->Button(-text => 'Apply', -command => [\&edit_entry, $idx, $legentry]) ->pack(-side => 'left'); $cmds->Button(-text => 'Delete', -command => sub {&delete_entry($idx);$tl->destroy;}) ->pack(-side => 'left'); } else { # New activity - OK Apply Cancel $cmds->Button(-text => 'OK', -command => sub {&add_entry($legentry);$tl->destroy;}) ->pack(-side => 'left'); $cmds->Button(-text => 'Apply', -command => [\&add_entry, $legentry]) ->pack(-side => 'left'); } $cmds->Button(-text => 'Cancel', -command => [$tl => 'destroy'])->pack(-side => 'left');