Please be advised that the norm is to include, if not the full, then a compilable/working sub-set of the, code that, when run, manifests the problem(s) you encountered on the way. Having said that...
use warnings; use strict; use Data::Dumper; my @files = <DATA>; chomp @files; warn Dumper \@files; sub get_least($) { my $md5 = shift; my $num = ( sort map { s/${md5}_//; s/_max//; ($_) } grep /^$md5.*_max/, @ +files )[0]; warn("No max file"), return undef unless $num; return $num; } warn get_least(q/111aaa222ccc324567fed54333221235/); warn get_least(q/777aaa222ccc324567fed54333221235/); warn get_least(q/99999999999999999999999999999999/); __DATA__ 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 99999999999999999999999999999999_1.04 99999999999999999999999999999999_1.07_min 99999999999999999999999999999999_1.04_min
when run, gives
$ perl tst.pl $VAR1 = [ '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', '99999999999999999999999999999999_1.04', '99999999999999999999999999999999_1.07_min', '99999999999999999999999999999999_1.04_min' ]; 1.02 at tst.pl line 22, <DATA> line 11. 1.04 at tst.pl line 23, <DATA> line 11. No max file at tst.pl line 18, <DATA> line 11. Use of uninitialized value in warn at tst.pl line 24, <DATA> line 11. Warning: something's wrong at tst.pl line 24, <DATA> line 11.
which, I believe, is as required.

A user level that continues to overstate my experience :-))

In reply to Re: File sort and values in file name by Bloodnok
in thread 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.