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