in reply to Is there an andand for Perl like there is in Ruby?

In

say $shop->ShopperDueDate->andand->day_name();
the say statement isn't conditional, as it is in the if form. So what is say supposed to do — that is, what is its argument supposed to be — when $shop->ShoppperDueDate is false?

One technique you could consider — using $_ as a sort of alias for the value from some other expression (this is called a "topicalizer" in Perl 6 land):

$_ and say $_->day_name for $shop->ShopperDueDate;
But it's not entirely unugly.

Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.

Replies are listed 'Best First'.
Re^2: Is there an andand for Perl like there is in Ruby?
by bart (Canon) on Jan 08, 2009 at 09:01 UTC
    $_ and say $_->day_name for $shop->ShopperDueDate; But it's not entirely unugly.
    Indeed. But there is another way. A while ago, tye pointed me out that || (and friends), when the whole expression is in list context, return their RHS in list context too. So you can make this:
    say $_->day_name for $shop->ShopperDueDate || ();
    which will indeed skip the loop body if the LHS evaluates to false.