programming-examples/perl/Subroutine/Using closures.pl

11 lines
222 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl
sub errorMsg {
my $lvl = shift;
return sub {
my $msg = shift;
print "Err Level $lvl:$msg\n";
};
}
$severe = errorMsg("Severe");
&$severe("Divide by zero");