Reputation: 5
I would like to do is to have a button to close my window (button_window), but also call a function (user_info):
my $btn = $main -> Button (-text => 'Start',
-command => sub {$button_window -> destroy},
-command => \&user_info)
-> pack ();
its executing only the last command thanks in advance
Upvotes: 0
Views: 334
Reputation: 26
The sub can take any number of calls to other subs.
my $btn = $main->Button(
-text => 'Start',
-command => sub {
user_info();
# do something else...
$button_window->destroy;
},
)->pack();
It's executing only the last command because a hash parameter can have only one '-command' key, so is overwritten.
Upvotes: 1