0

私がやりたいのは、ウィンドウを閉じるためのボタン (button_window) だけでなく、関数 (user_info) を呼び出すことです。

my $btn = $main -> Button (-text => 'Start',
-command => sub {$button_window -> destroy},
-command => \&user_info)
-> pack ();

最後のコマンドのみを実行します よろしくお願いします

4

1 に答える 1

1

潜水艦は、他の潜水艦への呼び出しをいくつでも受けることができます。

my $btn = $main->Button(
    -text    => 'Start',
    -command => sub {
        user_info();
        # do something else...
        $button_window->destroy;
    },
)->pack();

ハッシュ パラメーターは「-command」キーを 1 つしか持てず、上書きされるため、最後のコマンドのみを実行しています。

于 2016-04-12T07:48:34.720 に答える