On 2020-05-06 William Michels via perl6-users <perl6-users@perl.org> wrote: > Are there any other "operators that modify their operands" in > Raku/Perl6 that don't require an initializing "." (dot)? The dot is used to call a method on an object. > I checked the "subst" command and it requires an initial ".=" when > used with the "-pe" one-liner flag: ``subst`` is a method https://docs.raku.org/type/Str#method_subst To summarise: * ``-e`` tells raku "execute the next argument as a program" * both the ``-p`` and ``-n`` command-line switches wrap the program in a loop like:: for $*ARGFILES.lines -> { } ``-p`` additionally puts a ``say $_`` at the end of the block * inside that loop, the variable ``$_`` will have its value set to each line of the input, one at a time * you can do whatever you want inside the loop * the dot calls a method, and if you don't specify an object to call the method on (on the left hand side of the dot), ``$_`` is used * some operators (like ``s///`` or ``tr///``) operate on ``$_`` unless told otherwise * assignment (``=``) can be combined with other operators (``+=``, ``/=``, ``.=``, ``~=``, &c) If, having seen all that, the behaviour of all your examples is still not clear, maybe you should start writing your programs without shortcuts and implicit terms: the languages in the Perl family are very good at letting you write compact code, but sometimes this comes at the expense of clarity. While learning, code that's clear, explicit, and straightforward is often more helpful. -- Dakkar - <Mobilis in mobile> GPG public key fingerprint = A071 E618 DD2C 5901 9574 6FE2 40EA 9883 7519 3F88 key id = 0x75193F88Thread Previous | Thread Next