programming-examples/perl/Subroutine/A closure is an anonymous subroutine.pl
2019-11-15 12:59:38 +01:00

8 lines
153 B
Perl

my $name="Tommy";
{ my $name = "Tom";
my $age = 6;
$ref = sub{ return "$name is $age.\n"; }
}
print "$name is back\n";
print &{$ref};