Re: Inconsistency between one-liner flags (-ne, -pe) using chop example?

2020-05-06 Thread William Michels via perl6-users
Dear Laurent (and Gianni), So if the following code does useless work: perl6 -pe '.chop' demo1.txt why doesn't it fail with an error, "Useless use of ... in sink context (line 1)"? Best, Bill. On Tue, May 5, 2020 at 12:43 PM Laurent Rosenfeld wrote: > > In: > perl6 -ne 'put .chop' demo1.txt >

Re: Inconsistency between one-liner flags (-ne, -pe) using chop example?

2020-05-06 Thread Gianni Ceccarelli
On 2020-05-06 William Michels via perl6-users wrote: > So if the following code does useless work: > > perl6 -pe '.chop' demo1.txt > > why doesn't it fail with an error, "Useless use of ... in sink context > (line 1)"? That's a very good question! My best attempt at an answer: * subroutines t

Re: Inconsistency between one-liner flags (-ne, -pe) using chop example?

2020-05-06 Thread William Michels via perl6-users
Thank you, Gianni (and Laurent). I really appreciate you both taking the time to explain the intricacies of Raku/Perl6. Sincerely, Bill. On Wed, May 6, 2020 at 3:46 AM Gianni Ceccarelli wrote: > > On 2020-05-06 William Michels via perl6-users > wrote: > > So if the following code does useless w

More questions on the "-pe" one-liner flag: in conjunction with s/// and tr///

2020-05-06 Thread William Michels via perl6-users
Hello, Can anyone answer why--in a one-liner using the "-pe" flag--the s/// and tr/// functions do not require a "." (dot) preceding the function call? Clearly adding a "." (dot) before either one results in an error (code below). Also, adding a ".=" (dot-equals) sign before the either the s/// or

Re: More questions on the "-pe" one-liner flag: in conjunction with s/// and tr///

2020-05-06 Thread Gianni Ceccarelli
On 2020-05-06 William Michels via perl6-users wrote: > Can anyone answer why--in a one-liner using the "-pe" flag--the s/// > and tr/// functions do not require a "." (dot) preceding the function > call? Because they're not function calls, but *mutating* operators. As the documentation says https

Re: More questions on the "-pe" one-liner flag: in conjunction with s/// and tr///

2020-05-06 Thread Laurent Rosenfeld via perl6-users
The s/// substitution operator is not a method (and tr/// also not). They both modify their operands, so there is no need anyway for a '.=' syntax, since they do already what the '.=' syntax is aimed at. Cheers, Laurent.

Re: More questions on the "-pe" one-liner flag: in conjunction with s/// and tr///

2020-05-06 Thread William Michels via perl6-users
Thank you Laurent! Are there any other "operators that modify their operands" in Raku/Perl6 that don't require an initializing "." (dot)? I checked the "subst" command and it requires an initial ".=" when used with the "-pe" one-liner flag: mbook:~ homedir$ perl6 -pe '.=subst(/love|like/, "admir