You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
286 B
Perl
14 lines
286 B
Perl
5 years ago
|
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");
|