Help for this page

Select Code to Download


  1. or download this
    delete $log_count{$a--} if it=0;
    
  2. or download this
    delete $hash{some_destructive_function()} if it==0
    
  3. or download this
    $code = c{ $a = 1; $b=2; print $a + $b}
    
  4. or download this
    sub printer {
      my $expr = shift;
    ...
        }
      }
    }
    
  5. or download this
    $adder_code = printer( c{ $x + $y } }
    $adder_sub = compile($adder_code)
    ...
    $pythago_sub = compile($pythago_code)
    &{$pythago_sub}(3, 4)
    # prints 5
    
  6. or download this
    macro printer {
      my $expr = shift;
    ...
        }
      }
    }
    
  7. or download this
    # printer is a macro, so $x + $y is not evaluated
    $adder_sub = printer( $x + $y }
    &{$adder_sub}(1, 2)
    # prints 3
    
  8. or download this
    macro aif {
      my $condition = shift;
    ...
        }
      }
    }
    
  9. or download this
    aif(number_of_widgets(),
        {
          print "there are $it widgets\n";
        }
    )