in reply to Sorting challenge
Don't expect the user input to contain your exit condition. Instead, accept all user input (until EOF which terminates the program) and then filter the results.
chomp( my @input = <STDIN> ); for (sort { $a <=> $b } @input) { next if /\D/; last if $_ > 1_000_000; print "$_\n"; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting challenge
by PerlSufi (Friar) on Jul 22, 2013 at 21:40 UTC |