to find latest date in DD-MM-YYYY.
for (my $i=0;$i<$size;$i++) { #print "\n". $date[$i]; @yeardate[$i] = substr($date[$i],6,4); @monthdate[$i] = substr($date[$i],3,2); @daydate[$i] = substr($date[$i],0,2); } #print "\n array of date is : @date\n"; #print "\n array of year is : @yeardate\n"; #print "\n array of month is : @monthdate\n"; #print "\n array of day is : @daydate\n"; #------------------------------------------------ my $x=-1; $max_year = $yeardate[0]; foreach $yeareach (@yeardate[1..$#yeardate]) {$x++; $max_year= $yeareach if $yeareach gt $max_year; } #print"\n max_year is :" .$max_year. "\n\n"; #------------------------------------------------------------------ $y = 0; $max_month = $monthdate[0]; foreach $montheach (@monthdate[1..$#monthdate]) { $y++; $max_month= $montheach if (($montheach >= $max_month) && ($yeardate[$y +] == $max_year)); } #print"\n max_month is ".$max_month. "\n\n"; #-------------------------------------------------------------- $z = 0; $max_day = $daydate[0]; foreach $dayeach (@daydate[1..$#daydate]) { $z++; $max_day= $dayeach if (($dayeach >= $max_day) && (@yeardate[$z] == $ma +x_year)&& (@monthdate[$z] == $max_month)); } #print"\n".$max_day. "\n\n"; #---------------------------------------------------------------- $latestdate = $max_day."-".$max_month."-"."$max_year"; print "\n\nFolder with latestdate: ". $latestdate. "\n\n"; #----------------------------------------------------------------

In reply to Re^3: Max date from set of dates by perlVIP
in thread Max date from set of dates by Anonymous Monk

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.