Help for this page

Select Code to Download


  1. or download this
    my $pdispatch = {
        '+' => sub { $_[0] + $_[1] },
    ...
    # and later ...
    my $operator = qw(+ - * /)[int rand 4];
    my $true_answer = $pdispatch->{$operator}->($value1, $value2);