|
|
| Perl: the Markov chain saw | |
| PerlMonks |
Re: Scalar joining, concatenation, involving varying textby tlm (Prior) |
| on Jun 27, 2005 at 16:16 UTC ( [id://470372]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
Update: Quotation bug fixed. (In the original version of my solution the RHS of the concat/assignment in the eval was the single-quoted '$_=\$$_ ', resulting in $combined ending up with the value 'a=$a c=$c' instead of 'a=1 c=1'). Also, to clarify what the eval is doing, at each iteration, only the $_ get interpolated; the remaining $'s are quoted verbatim. Hence, in the first iteration, the argument to eval is the string All the a's in this string come from interpolating $_, whereas the $'s come from the \$'s in the original double-quoted expression. The fuss with double quotes and backslashes is a way to selectively interpolate certain values (i.e. $_'s); without all the backslashing, perl would try to interpolate $$, for example. Perhaps this is a clearer alternative: Of course, in the last snippet, $template can alternatively be set to or
the lowliest monk
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||