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