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:

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 *<
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 reply to Re: Please help me understand string eval better by AnomalousMonk
in thread Please help me understand string eval better by perltux

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.