Last active
December 7, 2015 11:35
-
-
Save note103/6cbccac4715779b07bb6 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
{ | |
my $count = 0; | |
sub counter { | |
say $count++; | |
} | |
} | |
counter(); #=> 0 | |
counter(); #=> 1 | |
counter(); #=> 2 | |
# see also: | |
# http://dqn.sakusakutto.jp/2009/12/perl_9.html | |
# http://www14.atpages.jp/jelfe/07/21.html | |
# http://d.hatena.ne.jp/naoya/20060109/1136812096 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment