Cheers - L~R#!/usr/bin/perl use strict; use warnings; my $count_1 = iterator( 1 ); print $count_1->(), "\n" for 1 .. 10; my $count_2 = iterator( 'a' ); print $count_2->(), "\n" for 1 .. 10; sub iterator { my $iterator = shift; return sub { $iterator++ }; }
In reply to Re: Closure question
by Limbic~Region
in thread Closure question
by Pug
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |