That's weird. Why are you changing the binding? You should just change the speed. Here's how I understood your description:
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
{ my $speed = 0;
sub change_speed {
my $diff = shift;
my $state = $speed <=> 0;
if (! $state || $state == ($diff <=> 0)) {
$speed += $diff if abs($speed + $diff) <= 100;
} else {
$speed = 0;
}
}
sub create_label {
my $parent = shift;
return $parent->Label(-textvariable => \$speed,
-relief => 'sunken',
)->pack(-ipadx => 5)
}
}
my $mw = 'MainWindow'->new(-title => 'Motor');
my $mf = $mw->Frame->pack;
$mf->Label(-text => 'Tk Motor Controller')->pack;
my $l = create_label($mf);
my $bf = $mf->Frame->pack;
$bf->Button(-text => '<',
-command => [ \&change_speed, -10 ],
)->pack(-side => 'left');
$bf->Button(-text => '>',
-command => [ \&change_speed, 10 ],
)->pack(-side => 'right');
my $qb = $mf->Button(-text => 'Quit',
-underline => 0,
-command => sub { Tk::exit() },
)->pack( -pady => 10);
$mw->bind('<Alt-q>', sub { $qb->invoke });
MainLoop();
Update: Used closure over the $speed variable.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|