in reply to extract only smallest numbers

Yes there is - there are many ways in fact. To get started you need to take a look at open, close, perldata (hashes in particular), perlsyn (while loops) and perlop (the diamond operator: '<FILEHANDLE>'), then take a stroll through the Tutorials section here.

When you've done all that and written your first attempt at the code, come back here with any problems you might have.


DWIM is Perl's answer to Gödel