The first "flattens" $x and $y to their integer literal values (2, 3) and passes that to add ...
I would express this somewhat differently. The word "flattens" brings to my mind the idea of "list flattening," which is not, as I see it, at work here. Instead, I would say that in the expression
eval("$x, $y")
the double-quote operator first interpolates the in-scope $x $y variables into a string, and then passes the string, in this example "2, 3", a very simple source code string literal list expression, to eval to process, and indeed, eval returns just that list.
... the 2nd passes the variable names ($x, $y), which are then resolved to their values in add.
Again, I would express this differently. I would say that eval is passed the "raw" string '$x, $y' (single-quotes don't interpolate) and it is eval that resolves these variables to their values in the course of evaluating this string of Perl code, then returning the result of the evaluation. Nothing is resolved in add.
In both cases, eval returns and add is passed exactly the same (2, 3) list. In the second case, eval has a bit more work to do to achieve the same final result.
Give a man a fish: <%-{-{-{-<
In reply to Re^6: tk option+value in variable?
by AnomalousMonk
in thread tk option+value in variable?
by cniggeler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |