my %dispatch = ( incr => sub { $x++ }, decr => sub { $x-- }, ); $dispatch{$op}->();