Created
February 24, 2009 02:29
-
-
Save tyru/69346 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 utf8; | |
use Encode qw( encode ); | |
use FileHandle; | |
use Getopt::Long; | |
use Perl6::Say; | |
use Pod::Usage; | |
say "closure test begin."; | |
say "-----------------------"; | |
my @arrays = qw( hoge foo bar ); | |
for( @arrays ) { say } | |
say "-----------------------"; | |
my $clos = sub { push @arrays, shift }; | |
$clos->( 'test' ); | |
$clos->( 'aaa' ); | |
for( @arrays ) { say } | |
say "-----------------------"; | |
my $clos2 = sub { \@arrays }; | |
sub { | |
my $clos = shift; | |
my $array_ref = $clos->(); | |
while( my $_ = shift @$array_ref ) { say $_; } | |
}->( $clos2 ); | |
say '--- say each @arrays ---'; | |
for( @arrays ) { say } | |
say "-----------------------"; | |
say "test end."; | |
__END__ | |
=head1 NAME | |
=head1 SYNOPSIS | |
=head1 OPTIONS | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment