programming-examples/perl/Subroutine/A closure is an anonymous subroutine.pl

8 lines
153 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
my $name="Tommy";
{ my $name = "Tom";
my $age = 6;
$ref = sub{ return "$name is $age.\n"; }
}
print "$name is back\n";
print &{$ref};