in reply to Re: Re: need helping sorting
in thread need helping sorting

Oops, need to specify the path when using stat():
opendir(FILES, $SAVE_DIRECTORY); @allfiles = sort { (stat "$SAVE_DIRECTORY/$a")[9] <=> (stat "$SAVE_DIR +ECTORY/$b")[9] } (grep(!/^\.\.?$/,readdir(FILES))); closedir(FILES); foreach $file (@allfiles) { print "$file " . (stat "$SAVE_DIRECTORY/$file")[9] . "\n"; } exit;
The number at the end is the modify date in Unix epoch format. You may want to translate it to a more readable format, but I can't remember how to do that right now (WAY too much Java this week).

Update: I think the module to convert the epoch date to a more useable one is Date::Manip, if I recall correctly.

Hot Pastrami

Replies are listed 'Best First'.
Re: Re: Re: Re: need helping sorting
by bbfu (Curate) on Mar 15, 2001 at 03:57 UTC

    You aught to just be able to do a scalar(localtime((stat "$SAVE_DIRECTORY/$file")[9])) to convert it to a fairly nicely formatted string. Date::Manip would be a lot more flexible/powerful, though...

    bbfu
    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.