14 lines
286 B
Perl
14 lines
286 B
Perl
|
sub paint {
|
||
|
my $color = shift;
|
||
|
my $ref = sub {
|
||
|
my $object=shift;
|
||
|
print "Paint the $object $color.\n"; # $color still in scope
|
||
|
};
|
||
|
return $ref;
|
||
|
}
|
||
|
|
||
|
my $p1=paint("red");
|
||
|
my $p2=paint("blue");
|
||
|
|
||
|
$p1->("flower");
|
||
|
$p2->("sky");
|