Re: The distinction between "do BLOCK while COND" and "EXPR while COND" should go

[email protected] (Tom Christiansen) Thu, 31 Aug 2000 13:16:49 -0600
Newsgroups perl.perl6.language.flow
Message-ID <4503.967749409@chthon>
>However, I really don't want to see 'return' become a kind of 'last'
>for do{}.  How would I return from a subroutine from within a do loop?

You already can't do that (as it were) from within an eval.  

But I while I am not completely bothered by letting the value
dangle here:

    ($msg, $defstyle) = do {  
	my $i = find_when($orig);
	$i == 1 ? ("First", "Color" )  :
	$i == 2 ? ("Then",  "Rarity")  :
		  ("Then",  "Name"  )
    };

or here:

    ($FORMAT_NAME, $FORMAT_TOP_NAME) = do {
        if    ($long_form)      { qw( Long      Long_Top   ) }
        elsif ($just_inode)     { qw( Inodes    Inodes_Top ) }
        elsif ($sys5)           { qw( SysV      SysV_Top   ) }
        elsif ($bsd)            { qw( BSD       BSD_Top    ) }
        else                    { die " No format?"          } 
    };

It just kinda irks me here:

    $total += 2 * do {
	my $count = 0;
	for $n (@nums) { $count += $n }
	$count;
    };

I rather that were:

    $total += 2 * do {
	my $count = 0;
	for $n (@nums) { $count += $n }
	return $count;
    };

--tom