I ran into a problem using the eval function.
Indeed, I have some kind of function name inside the SQL database, my goal is to execute these functions in perl (after extraction in SQL).
Here's what I do, given that $ RssSource β {$ k} {Proceed} contains "& test" as a string derived from SQL:
my $str2 = "ABCD"; eval "$RssSource->{$k}{Proceed}";warn if $@ ; sub test { my $arg = shift; print "fct TEST -> ", $row, "\n"; }
This works correctly and displays:
fct TEST ->
However, I would like to be able to pass $ str2 as an argument to $ RssSource β {$ k} {Proceed}, but I donβt know how every syntax I tried returned an error:
eval "$RssSource->{$k}{Proceed}$str2" eval "$RssSource->{$k}{Proceed}($str2)" eval "$RssSource->{$k}{Proceed}"$str2 eval "$RssSource->{$k}{Proceed}"($str2)
Can someone tell me how to pass the argument of the evaluated function correctly?
Many thanks for your help
Sincerely.
Florent
source share