I have a problem with the following block of code. It works fine when
there isn't a *.log file in the same directory as the script but when
there is, it always returns that log as the newest file and ignores the
list of files it retrieves from the remote server.
I debugged this and found that the READDIR is working but the last
element in the list is the log file that is in the script directory.
Never heard of such a thing. readdir gets only files in the directory which you have opened
What can I do to make sure I get the list of *.log files on the remote machine regardless of what exists in my working local directory?
<snip>
Just try adding these line
$iisdir = '\\\server01\c$\winnt\system32\logfiles\W3SVC1'; opendir LOGS, "$iisdir" or die "Directory error for IIS LOGS: $!\n";
my @files = grep /\.log$/, readdir LOGS;
# -M $a would work only if you are already in that dir .... so chdir $iisdir;
@files = sort { -M $a <=> -M $b } @files;
# if you dont like that give the full path in $a and $b
# I think it is reverse sorted
$active_log = $files[-1]; # this should be the newest file rather than
$active_log = $files[0];
a log in the local directory that the script is running from.
--Paul
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>