"so" coerces to True or False. "say /c/" would output the match object "say
so /c/" says True. Depends on what you want to see.

" $x ?? $y !! $z" is a shortcut - "if $x use value of $y else use value of
$z" and ought to be used for the final value.
You may know it in perl5 as "$result = $x ? $y : $z"
Here I use it to avoid typing "if {} else {}" - a similar shortcut is
s/foo/bar/
|| say 'Failed!'

.say is a quick way of saying $_.say -a dot without any variable,
expression before it means "call this method on the topic variable which is
$_"

-y

On Tue, Aug 14, 2018 at 1:04 PM, ToddAndMargo <toddandma...@zoho.com> wrote:

> On 08/14/2018 08:29 AM, yary wrote:
>
>> Or, store the string in $_, and take advantage of less to type-
>>
>> perl6 -e '$_="abc"; say so /z/; say so /b/; s/c/defg/ ?? .say !! say
>> "Failed!"'
>>
>>
>>
>> -y
>>
>
> Thank you!
>
> Well I can see it working, but what does
>
>    "so"
>    "??"
>    ".say"
>    "!!"
>
> do?
>
>
> My actual code will look something like
>
> p6 'my $x="abc"; if not ( (my $y = $x) ~~ s/b/1/ && $y ~~ s/c/2/ ) {say
> "failed"}else{say "worked"}; say "$y";'
>
> worked
> a12
>

Reply via email to