use strict; use warnings; use feature 'say'; # a hash of code refs is an idiomatic dispatch table my %op = ( add => sub { $_[0] + $_[1] }, mul => sub { $_[0] * $_[1] }, ); say $op{add}->(2, 3); say $op{mul}->(2, 3);
a hash of code refs