Created
July 13, 2015 14:05
-
-
Save tadzik/80987d58011eeff3d96f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
┌─[tadzik@dagobah]─[~] | |
└─[%]─> cat test.pl | |
use 5.018; | |
my @closures; | |
for my $i (1..10) { | |
push @closures, sub { say "I'm sub number $i" } | |
} | |
for (@closures) { | |
$_->(); | |
} | |
┌─[tadzik@dagobah]─[~] | |
└─[%]─> perl test.pl | |
I'm sub number 1 | |
I'm sub number 2 | |
I'm sub number 3 | |
I'm sub number 4 | |
I'm sub number 5 | |
I'm sub number 6 | |
I'm sub number 7 | |
I'm sub number 8 | |
I'm sub number 9 | |
I'm sub number 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment