in reply to Re^3: Parsing by indentation
in thread Parsing by indentation

/msg tybalt89 After all, I thought I understood the line with the ternary operator, but it seems you're doing some other sort of magic with the double arrow operator. If you don't mind explaining this one too ^_^ ?

Replies are listed 'Best First'.
Re^5: Parsing by indentation
by hippo (Archbishop) on Oct 25, 2018 at 15:16 UTC

    If you are referring to the Here Document, search for '<<EOF' in perlop for more on that. They also get a mention at the end of the quotes in Perl tutorial (and in the replies).

      Oh I was talking about the => , since it seems it has many usages. But in this case it seems to be simply used to assign a value to a key in the hash structure. Have a great day !
        Oh I was talking about the => , since it seems it has many usages.

        Unlike a couple of other operators in Perl, the => operator, aka the "fat comma", only has one function that varies slightly depending on list vs. scalar context:

        The => operator (sometimes pronounced "fat comma") is a synonym for the comma except that it causes a word on its left to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores. This includes operands that might otherwise be interpreted as operators, constants, single number v-strings or function calls. If in doubt about this behavior, the left operand can be quoted explicitly.

        Otherwise, the => operator behaves exactly as the comma operator or list argument separator, according to context. ...

        ... In scalar context it evaluates its left argument, throws that value away, then evaluates its right argument and returns that value. This is just like C's comma operator.

        In list context, it's just the list argument separator, and inserts both its arguments into the list. These arguments are also evaluated from left to right.

        The operator is most commonly used when constructing hashes, but can be used anywhere a comma normally is, for example in arguments to subroutines: somefunc( foo => 123 ) is the same as somefunc('foo', 123).

Re^5: Parsing by indentation
by AnomalousMonk (Archbishop) on Oct 25, 2018 at 17:02 UTC

    Also see Here document for a general discussion.


    Give a man a fish:  <%-{-{-{-<