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");