On 09/30/2017 07:59 PM, Brandon Allbery wrote:
On Sat, Sep 30, 2017 at 10:30 PM, ToddAndMargo <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> wrote:

    On 09/30/2017 02:15 PM, Brandon Allbery wrote:

        Basically: < > is single quotes and treats variables and
        expressions as literals. << >> is double quotes and interpolates
        variables but not general expressions. And { } does no quoting
        at all and uses general expressions.


This gets a little complex...

    1) expressions

    2) the difference between "expressions" and "general expressions"


Doublequoted strings don't just expand variables. Postfixes (like [] or <> to look up values in arrays/hashes) are also understood; method calls on variables also work, as long as they end with a parenthesized expression (so, "hi $foo.name <http://foo.name>" will not work (it'll expand '$foo' instead of '$foo.name <http://foo.name>') but "hi $foo.name <http://foo.name>()" will, provided $foo contains an object with a 'name' method). This is what I meant by 'expression', which I should have probably called 'simple expression' or something.

    3) Quoting.  The difference between "" and <>


' ' strings and <> postfixes are almost identical. %foo<a> is the same as %foo{'a'}. But %foo<a b> acts like you did: %foo{'a'}, %foo{'b'} " " strings and << >> postfixes are almost identical. %foo<<a>> is the same as %foo{"a"}. But %foo<<a b>> acts like you did: %foo{"a"}, %foo{"b"}

Inside ' ' strings, everything is literal.
Inside " " strings, variables like $foo and (simple) expressions (described above) will be replaced by their values; and you can use { } to insert the result of any expression. (This also works in << >>.)

    pyanfar Z$ 6 'my %x = ("a"=>"b","c"=>"d", "e"=>"f"); my $v = "b"; say %x<<a {$v.succ}>>'
     (b d)

    4) "interpolating" as it refers to Perl (not math, where you "guess"
         what a value is based on values on both sides of you).


Replacing something inside a string with the string representation of its value. This sense is also used in documentation for the shell, where you can also interpolate `` subcommand output and such.

Hi Brandon,

What does the ".succ" do?


Is English your first Language?  I asked this because of your use
of the word "interpolate", which you used correctly.

Reference: http://www.wordnik.com/words/interpolate

You used it as to mean "insert":
    transitive v. To insert or introduce between other
    elements or parts.

As an Engineer, when I use the term, I am using it as:
    v. To estimate the value of a function between two
    points between which it is tabulated.


And neither one of us are using it as:
     transitive v. To change or falsify (a text) by introducing
     new or incorrect material.

     transitive v. To alter or corrupt by the insertion of new
     or foreign matter; especially, to change, as a book or text,
     by the insertion of matter that is new, or foreign to
     the purpose of the author.

Thank you!

-T

I will be reading your response over several times until is sinks in.

:-)

Reply via email to