Hi,
I did not have time before to answer in a detailed fashion.
This is an example (under the debugger) of the use of symbolic references:
DB<1> ($blue, $red) = qw / b r/;
DB<2> say ${$_} for qw /blue red/;
b
r
What is happening here is that the second line constructs the variable name $blue from the string "blue" (and the same for red). It works and prints the values of the variables initialized in the first line. It works, yes, but we all know that this technique is very much frown upon, to the point that it is forbidden under the strict pragma, as shown with this one-liner:
$ perl -Mstrict -E 'our ($blue, $red) = qw / b r/; say ${$_} for qw /
+blue red/;'
Can't use string ("blue") as a SCALAR ref while "strict refs" in use a
+t -e line 1.
Why does it work? Because it is constructing an entry (variable name) that can be found in the symbol table.
You can even construct the name with concatenation, doing it this way:
DB<3> say ${ "bl" . "ue"};
b
Now the reason I was worried about the OP's code is that the way it constructs the subroutine name is quite similar, and with essentially the same intent: to create a name and look up the symbol table for the subroutine name.
Again, I'm not saying this is bad, I'm just asking other monks what they think about it.
|