I am looking for a way to call a function awk
by name, i.e. using a string entered by the user.
My goal is to replace a lot of code this way ...
if (text == "a") a(x)
if (text == "b") b(x)
if (text == "c") c(x)
... with any method of sending to a function using a string name something like this:
send(text, x)
In other languages, this effect is sometimes described as reflection, sending messages, or dynamically sending or receiving a function pointer by name.
I am looking for a way to do this using gawk
and ideally also using POSIX portable awk
.
source
share