sub create_counter { my $counter = 0; return sub { $counter++ }; } # # # my $counter = create_counter(); while (&$counter < $Some_Value) { &DO_Stuff; } #### sub create_upper_bounded_counter { my ($upper_bound) = @_; my $counter = 0; return sub { $counter++ <= $upper_bound ? 1 : 0 }; } # # # my $bounded_counter = create_upper_bounded_counter(10); while (&$bounded_counter) { &Do_Stuff; }