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

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 !

Replies are listed 'Best First'.
Re^7: Parsing by indentation
by haukex (Archbishop) on Oct 26, 2018 at 14:00 UTC
    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).