in reply to RFC: Perl5 Language Extension: Definedness-Triggered Shortcut Operators

For defined-or we already have //.

As far as the other two go, take a look at PerlX::Perform which I believe should allow you to do defined-and and defined-dereference, albeit with more verbose syntax.

For example, imagine that $bob->spouse might return a Person object, or might return undef if Bob isn't married. Then PerlX::Perform allows:

$bobs_wifes_name = perform { $_->name } wherever $bob->spouse;

If the wherever expression evaluates to undefined, then the perform keyword returns undef (or the empty list if called in list context). If the wherever expression evaluates to a defined value (even if that value is false) then that value is assigned to $_ and the perform block is triggered.

PerlX::Perform also offers an alternative syntax which works more or less the same way. Note that the alternative syntax uses a comma, whereas the syntax above does not.

$bobs_wifes_name = wherever $bob->spouse, perform { $_->name };

So your A :&& B can be written as:

wherever A, perform {B}

And your A:->B can be written as:

wherever A, perform {$_->B}

Do give PerlX::Perform a try. Patches for improved performance, or more sugary syntax are likely to be accepted.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'