I would use File::Find to get the latest file in many directory. After I test the code,I found that code work normal if I send one directory to File::Find. But it would get wrong result if I send more than one directory to module. It seems like that File::Find would remember the variable.

#!/usr/bin/perl use File::Find; $file = "/home/cmbnms/data/tftp/99.1.124.251"; my ($saved_time, $saved_name) = (-1, ''); sub biggest { if(-f $File::Find::name) { if ((stat($File::Find::name))[9] > $saved_time) { $saved_time = (stat($File::Find::name))[9]; $saved_name = $File::Find::name; } } return; } @dir = ($file); find(\&biggest, @dir); print "Biggest file $saved_name in is $saved_time long.\n"; $file = "/home/cmbnms/data/tftp/99.1.124.252"; @dir = ($file); find(\&biggest, @dir); print "Biggest file $saved_name in is $saved_time long.\n"; $file = "/home/cmbnms/data/tftp/10.1.102.237"; @dir = ($file); find(\&biggest, @dir); print "Biggest file $saved_name in is $saved_time long.\n"; $file = "/home/cmbnms/data/tftp/10.1.99.100"; @dir = ($file); find(\&biggest, @dir); print "Biggest file $saved_name in is $saved_time long.\n"; $file = "/home/cmbnms/data/tftp/10.1.99.200"; @dir = ($file); find(\&biggest, @dir); print "Biggest file $saved_name in is $saved_time long.\n";
execute result is like this:
Biggest file /home/cmbnms/data/tftp/99.1.124.251/2005-9-/15-20-24-99.1 +.124.251.conf in is 1126164026 long. Biggest file /home/cmbnms/data/tftp/99.1.124.252/2005-9-8/15-20-26-99. +1.124.252.conf in is 1126164027 long. Biggest file /home/cmbnms/data/tftp/10.1.102.237/2005-9-8/17-21-30-10. +1.102.237.conf in is 1126171290 long. Biggest file /home/cmbnms/data/tftp/10.1.102.237/2005-9-8/17-21-30-10. +1.102.237.conf in is 1126171290 long. Biggest file /home/cmbnms/data/tftp/10.1.102.237/2005-9-8/17-21-30-10. +1.102.237.conf in is 1126171290 long.

you can see that the last 3 result is same, but it is not truth.

thanks for your help!

Considered: marto: Retitle : "Possible File::Find bug" ?
Unconsidered: Chady: enough keep votes (edit:16 keep:23 del:0)


In reply to bug of File::Find ? by iwanthome

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.