Help for this page

Select Code to Download


  1. or download this
    sub counter {
       my $start_value = shift;
       return sub { return $start_value++; }
    }
    
  2. or download this
    my $counter1 = counter(5);
    my $counter2 = counter(20);
    print $counter1->(), $counter1->(), $counter1->(),"\n";
    print $counter2->(),"\n";
    print $counter1->(),"\n";
    
  3. or download this
    567
    20
    8
    
  4. or download this
    sub build_one {
       my($foo, $bar, $baz) = @_;
    ...
    push @queue, build_one($alpha, $beta, $gamma);
    
    # repeat as necessary.
    
  5. or download this
    map { $_->($last_thing) } @queue;