What is supposed to happen is that the user is to be prompted to keep entering numbers until an acceptable one is entered but the program just goes to next line of code even when numbers out of range are entered. What am I doing wrong?

Well, if you want to sort all the positive integers from 1 to 50,000, just don't sort them and don't even look at your database. Just print them in their natural order:

Thanks, but the exercise is to emulate a database so I'm pulling out a section of the numbers from 1 to 50,000 and then giving the user the option to do things like display only prime numbers, or exclude numbers starting with 3 or ending with 8, etc.

In Reply To

Do not assume that the user has entered the right data, validate it. I recommend the use of a module for prompting.

Thanks, but I'm just starting with Perl so I'll wait to add modules until I understand enough of the basics.