Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Sorting challenge

by jeffa (Chancellor)
on Jul 22, 2013 at 21:35 UTC ( #1045733=note: print w/ replies, xml ) Need Help??


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)


Comment on Re: Sorting challenge
Select or Download Code
Re^2: Sorting challenge
by PerlSufi (Friar) on Jul 22, 2013 at 21:40 UTC
    Thanks, jeffa. Good call. I'll try this out when I can

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045733]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (14)
As of 2015-05-06 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    In my home, the TV remote control is ...









    Results (145 votes), past polls