Help for this page

Select Code to Download


  1. or download this
    {
        my $closure;
        sub x1 { $closure = shift if @_; $closure }
    }
    
  2. or download this
    sub x1 { state $closure; $closure = shift if @_; $closure }
    
  3. or download this
    sub x1 { state $closure ... }
    sub x2 { state $closure ... }
    
  4. or download this
    $ perl -le 'sub x { our $c = shift if @_; $c } $::c = 1; print for x()
    +, x(2)'
    1
    2