in reply to Re: bug of File::Find ?
in thread bug of File::Find ?
_latest("dire1"); ...do something... _latest("dire2"); ...do something... _latest("dire3"); ...do something... _latest("dire4"); ...do something... sub _latest{ my $file = shift; my @dir; my $saved_time = -1; my $saved_name = ''; sub wanted { 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; } } } @dir = ($file); find(\&wanted, @dir); return $saved_name; }
I don't know how to reset the variable to (-1, '') in this mode. In my opinion,every time I call _latest function,it reset the variable. But test result is not like that. It don't reset. Would you please help me ? thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: bug of File::Find ?
by ambrus (Abbot) on Sep 09, 2005 at 09:14 UTC |