in reply to Re: Most recently created file in a folder
in thread Most recently created file in a folder

Thanks to the enlightened Ones,...

But I can't use this bit of code on a remote Win32 PC! I don't get any output!

this all what I did
use constant ATIME => 9; use constant MTIME => 10; use constant CTIME => 11; my $dir = "\\\\Sn007a_srv\\c\$\\program files\\common files\\sysadmin\ +\log\\ApplicationSynchronizer"; my $time = CTIME; my @files = map{ scalar localtime($_->[$time]). "\t" . $_->[0]} sort{ $b->[$time] <=> $a->[$time] } map{ [ $_, stat($_) ] } grep { -f } glob ( "$dir\\*" ); print "$files[0]\n";
Any way I can use a remote folder please?
Cheers

Replies are listed 'Best First'.
Re^3: Most recently created file in a folder
by bluto (Curate) on Sep 07, 2004 at 15:12 UTC
    Are you getting an error from the 'glob' call? To be honest, I'm not sure how to do that -- the documentation doesn't seem to mention it.

    My personal preference for reading a directory without recursion is to use opendir/readdir. That way, you can check for errors easier (e.g. does the full path exist, do you have permissions to access it, etc). You also don't have the overhead of using glob, nor relying on how the system decides to expand '*', which should be everything anyway (well, except for dot files under Unix).

    bluto