Hello,

Well after 2 days search, I give up and call for help :(

I have a list of files always on the same syntax:

string_amount_end

string is a 32 letters/digit chain (a md5 hash)
amount is always formatted with a digit and 2 decimals (1.00, 45.21, etc)
_end can be nul, or _min or _max
So a file name looks like 111aaa222ccc324567fed54333221235_1.02_max
or 111aaa222ccc324567fed54333221235_1.02
etc

I need to find all the files with the same "string" AND that have "_max" at the end, then inside those files I need to find the one where "amount" is the lowest.

So for example in the following list,:

111aaa222ccc324567fed54333221235_1.04
111aaa222ccc324567fed54333221235_1.05_max
111aaa222ccc324567fed54333221235_0.98_min
111aaa222ccc324567fed54333221235_1.02_max
111aaa222ccc324567fed54333221235_0.21
777aaa222ccc324567fed54333221235_1.04
777aaa222ccc324567fed54333221235_1.07_min
777aaa222ccc324567fed54333221235_1.04_max

if I am interested by the string 111aaa222ccc324567fed54333221235, the result should be 1.02 (from 111aaa222ccc324567fed54333221235_1.02_max)

Additionally I also need to know if there is no _max file at all in the selected files (that have the same "string").

Well I am a newbie, even a code of 20 lines didn't get the good result :(

Thank you for your help! (I add that it is not for business or exam etc, I am simply writing a game for my website :)


In reply to File sort and values in file name by natol44

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.