programming-examples/perl/Subroutine/Return a subroutine from a subroutine.pl

9 lines
191 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
sub printem
{
my $string1 = shift;
return sub {my $string2 = shift; print "$string1 $string2\n";};
}
$hellosub = printem("Hello");
&$hellosub("today.");
&$hellosub("there.");