in reply to Re^2: [Perl 6] Generalized shortcutting C<||>?
in thread [Perl 6] Generalized shortcutting C<||>?

In Perl5, this is roughly what you want as a function, in terms of argument ordering and short-circuiting.
sub cop { local $_ = shift; my ($cond, $default) = @_; $cond->() ? $_ : $default->(); } for my $test (2..4) { print "$test: ", cop($test, sub {$_ == 3}, sub { 'This is a default' + }), "\n"; }
I suspect Perl6 would make it more appetizing.

Caution: Contents may have been coded under pressure.