eval "$$var$transf"
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!c:\@Work\Perl\monks>perl -wMstrict -le "my $foo = 'rm '; my $var = \$foo; my $transf = '-R *'; ;; print qq{A: >$$var$transf<}; print 'B: >', $$var.$transf, '<'; print 'C: >', '$$var'.$transf, '<'; " A: >rm -R *< B: >rm -R *< C: >$$var-R *<
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 reply to Re: Please help me understand string eval better
by AnomalousMonk
in thread Please help me understand string eval better
by perltux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |