[PLUG] perl question

Mark Griskey mark at linuxhardware.net
Fri Nov 15 08:02:11 UTC 2002


Hi, 

Stat is the way to go:

$mtime=(stat($filename))[9];

then put it in a hash:

$all{$filename}=$mtime;

then sort it:

foreach $g(sort { $all{$a} <=> $all{$b} } keys %all){
print "$all{$g} $g\n";
#and do some noodling around here as well.
}

hope this helps.  

Mark



On Thursday 14 November 2002 04:28 pm, Matt Whiteley wrote:
> I am trying to rename a bunch of files in a directory into a consecutive
> pattern.  That was pretty easy, however I am trying to name them in
> order of the mtime of the file.  I have been messing around with
> File::stat, but this is above my knowledge of perl.  I am reading the
> llama book now but this problem just cropped up.  I also was reading the
> man perlfunc pages.  If one of you more talented types could help me out
> or point me in a different direction it would be greatly appreciated.
> Looking forward to meeting a bunch of you tomorrow.
>
> thanks,

-- 
------------------------
Mark Griskey
www.linuxhardware.net




More information about the PLUG mailing list