- or download this
my %h = (
func1 => sub { return sprintf ("0x%x", shift) },
func2 => sub { return sprintf ("%b", shift) },
func3 => sub { return sprintf ("%d", shift) },
);
- or download this
$h{func1}->();
- or download this
my %h = (
func1 => sub {
...
return sprintf ("%d", $value);
},
);
- or download this
sub foo {
# requires an even number of parameters in @_
...
# to call:
foo(qw/key1 val1 key2 val2 key3 val3/);
- or download this
sub foo {
# get singular hash reference with any number of key/value pairs
...
foo( 'key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3' );