Thread Code Review: Innerhalb einer for Schleife das verwendete Array verändern
(5 answers)
Opened by Kuerbis at 2013-06-30 17:21
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"; } |