Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use 5.010;
- use strict;
- use warnings;
- my %sub_func;
- %sub_func = (
- parent_dad => sub {
- print "\tcalled: sub parent_dad()\n";
- sub_func{child}->(); # <--- How to call another anonym sub from sub?
- },
- parent_mom => sub {
- print "\tcalled: sub parent_mom()\n";
- sub_func{child}->(); # <--- How to call another anonym sub from sub?
- },
- child => sub {
- print "\tcalled: sub child()\n";
- }
- );
- my @calls = qw(
- parent_dad
- parent_mom
- );
- foreach (@calls) {
- $sub_func{$_}->();
- }
Advertisement