in reply to extract only smallest numbers

Now that you've solved the problem with a perl script, you might still want to know that the unix/cygwin "sort" command does this, when you use the appropriate option flags -- e.g.:
sort -n +1 a_file > a_sorted_file
If you only want the first few lines, try the "head" command:
sort -n +1 a_file | head -5 > first_five_sorted