It gives me a undefined subroutine &main:: called at ... error. Anybody can give me some advice?$a = sub {return @_[0]}; (yes I know....) $b = sub {return @_[0]+1}; .... some code ..... if (something) $i = $a; else $i = $b; &lala ($i); sub lala{ my $i = $_[0]; $res = &{$i}($number) ; #have also tried $res = $i->($number) with the same result }
In reply to using reference to subroutine by kotoko
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |