I find it a bit weird that I have to wrap defined subroutines anonymously when specifying the -command
argument for Tkx widgets.
An excerpt from a TkDocs tutorial demonstrates this:
my $cb = $frm->new_ttk__button ( -text => "Calculate",
-command => sub {calculate();} );
sub calculate {
$meters = int(0.3048*$feet*10000.0+.5)/10000.0 || '';
}
Why doesn't it work when I write -command => &calculate()
or -command => \&calculate()
?