Welcome to the Monastery | |
PerlMonks |
Re: Please help me understand string eval betterby AnomalousMonk (Archbishop) |
on Jun 13, 2017 at 02:32 UTC ( [id://1192645]=note: print w/replies, xml ) | Need Help?? |
eval "$$var$transf" These two expresions are essentially the same. $$var.$transf is simply an explicit string concatenation that would be done implicitly in a "$$var$transf" double-quotish interpolation. (Update: The concatenation/interpolation is done at run time, and then the resulting string is eval-ed.) eval '$$var'.$transf This is a bit different. A literal string '$$var' (the dollar signs are part of the literal string) is explicitly concatenated with the stringization of whatever is in the $transf scalar. (Update: Again, the concatenation is done at run time and the resulting string is eval-ed.) Try experimenting with these string expressions — without the eval part until you're sure what's going on! Update 1: Note that $$var is the dereference of a reference to a scalar: $var holds a reference to some other scalar. Update 2: Some examples: Once again, experiment — it's fun and easy! Update 3: ... what gets done ... at compile time ...That's the eval BLOCK form. It's compiled at... well, compile time, and must be syntactically correct. (The eval EXPR form need not be.) Please see the docs for more info, get back to us with any specific questions. Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|