in reply to functional "given...when..."?

Is there another way to use given...when... in a "functional" way which avoids introducing a do statement and a dummy lexical?
No, in the same way you cannot do
my $r = if ($foo) then {"bar"} else {"baz"};
or
my $r = for (1, 2, 3) {$_ + 4};
But you can in ALGOL 68! ;-)

Replies are listed 'Best First'.
Re^2: functional "given...when..."?
by BrowserUk (Patriarch) on Mar 16, 2010 at 11:42 UTC

    I guess he was hoping that given when would work line if/then:

    print do{ if( $_ ){ 'foo' }else{ 'bar' } } for 0,1;; bar foo

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.