Thread Code Review: Innerhalb einer for Schleife das verwendete Array verändern (5 answers)
Opened by Kuerbis at 2013-06-30 17:21

Kuerbis
 2013-07-01 10:20
#168683 #168683
User since
2011-03-20
939 Artikel
BenutzerIn
[default_avatar]
Thx! Mit while schaut es gleich viel schöner aus und die Indices sind auch weg.

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
while ( @array ) {
    my $el = shift @array;
    my $choice = choose( 
        [ 'ok', 'ans Ende', undef ], 
        { prompt => "<$el>", undef => 'Exit' } 
    );
    exit if not defined $choice;
    if ( $choice eq 'ans Ende' ) {
        push @array, $el;
        next;
    }
    push @new, $el;
    say "@new";  
}

View full thread Code Review: Innerhalb einer for Schleife das verwendete Array verändern