$ cat test.pl
use strict;
use warnings;
sub route {
print "hello, world!";
}
my %h;
$h{'a'} = 'route';
print "1\n";
$h{a};
print "2\n";
$h{a}();
print "3\n";
"$h{a}".();
$ perl test.pl
Useless use of hash element in void context at test.pl line 12.
Useless use of concatenation (.) or string in void context at test.pl line 18.
1
2
Can't use string ("route") as a subroutine ref while "strict refs" in use at test.pl line 15.
$
Jaki jest właściwy sposób połączenia pod numer route()
?Jak mogę wywołać podprogram, którego nazwa jest wartością w mieszaniu, w Perlu?
możliwy duplikat [Jak wywołać nazwę funkcji zapisaną w haszowaniu w Perlu?] (Http://stackoverflow.com/questions/1836178/how-do-i-call-a-function-name -to-jest-przechowywany-w-a-hash-in-perlu) – Ether