# New Ticket Created by  "jason switzer" 
# Please include the string:  [perl #62178]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=62178 >


When mixing gather with a while loop, only the last element tested by the
while predicate seems to actually be gathered. I created a test to mix
gather and while in S04-statements/gather.t:

    my @list = gather {
        my $v = 1;
        while($v <= 10) {
            take $v if $v % 2 == 0;
            $v++;
        }
    };
    is ~...@list, "2 4 6 8 10", "gather with nested while";

At this point, @list only contains [11, 11, 11, 11, 11]. If the while loop
is replaced with a for loop (C<for(1..10) -> $f>), it properly returns [2,
4, 6, 8, 10].

Tested on: revision 35352 built on parrot 0.8.2-devel for
x86_64-linux-thread-multi.

Thanks,

Jason "s1n" Switzer

Reply via email to