sub foo { print "hello world" }; # more or less equivalent to: BEGIN { *foo = sub { print "hello world" }; } #### #!/usr/bin/perl use strict; use warnings; my $i = 1; sub counter_i { $i++ } sub counter_gen { my $j = shift; return sub { $j++ } } my @counters = ( \&counter_i, counter_gen(5), counter_gen(10) ); for ( 1 .. 10 ) { for my $c ( @counters ) { print $c->(), " "; } print "\n"; } #### 1 5 10 2 6 11 3 7 12 4 8 13 5 9 14 6 10 15 7 11 16 8 12 17 9 13 18 10 14 19