initial commit
[urisagit/Sort-Maker.git] / exp / closure.pl
1 #!/usr/local/bin/perl
2
3 use strict ;
4
5 sub make {
6         my $foo = 3 ;
7
8         my $sub = sub { print "sub called\n@_\n$foo\n", $foo + 1, "\n" } ;
9
10 my $n = eval <<'CODE' ;
11         my $s = $sub ;
12         sub { $s->(@_) }
13 CODE
14         return $n ;
15 }
16
17 my $m = make() ;
18
19 $m->('bar') ;
20