sub another {
    
    my $func = shift;
    my $val  = shift;

    
    return $func->($val);
};

sub reverser {
    return scalar reverse shift;
};


print another \&reverser, 'data';

print another sub {return scalar reverse shift}, 'data';



my %dispatch = (
    square => sub {return shift() ** 2},
    cube   => sub {return shift() ** 3},
    rev    => \&reverser,
);

print another $dispatch{$_}, 123 for qw(square cube rev);