Help for this page

Select Code to Download


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