sub foo {}
sub bar {}
sub baz {}
sub pick_at_random {
my %table = @_;
}
my %lookup = ( A => \&foo,
B => \&bar,
C => \&baz );
my $selected = pick_at_random( %lookup );
print $selected == \&foo ? "Got 'foo'" : $selected == \&bar ? "Got 'bar'" :
$selected == \&baz ? "Got 'baz'" :
"Got nadda" ;
c3ViIGZvbyB7fQpzdWIgYmFyIHt9CnN1YiBiYXoge30KCnN1YiBwaWNrX2F0X3JhbmRvbSB7CgogICAgbXkgJXRhYmxlID0gQF87CiAgICByZXR1cm4gKCB2YWx1ZXMgJXRhYmxlIClbIHJhbmQoIGtleXMgJXRhYmxlICkgXTsKfQoKbXkgJWxvb2t1cCA9ICggQSA9PiBcJmZvbywKICAgICAgICAgICAgICAgQiA9PiBcJmJhciwKICAgICAgICAgICAgICAgQyA9PiBcJmJheiApOwoKbXkgJHNlbGVjdGVkID0gcGlja19hdF9yYW5kb20oICVsb29rdXAgKTsKCnByaW50ICRzZWxlY3RlZCA9PSBcJmZvbyA/ICJHb3QgJ2ZvbyciIDoKICAgICRzZWxlY3RlZCA9PSBcJmJhciA/ICJHb3QgJ2JhciciIDoKICAgICRzZWxlY3RlZCA9PSBcJmJheiA/ICJHb3QgJ2JheiciIDoKICAgICAgICAgICAgICAgICAgICAgICAgICJHb3QgbmFkZGEiIDs=