O'Dear Monks
PLEASE HELP
I have the following script
use strict;
open (LST, "c:\\list.lst")||die "$^E : $!\n";
chomp (my @data=<LST>);
my $app_sync_dir = 'c$\program files\common files\ms sysadmin\log\Appl
+icationSynchronizer';
for (@data)
{
my $target_dir = "\\\\".$_."\\".$app_sync_dir;
print "$target_dir\n";
if (-e $target_dir)
{
opendir (DIR, $target_dir) || warn "\n$_ : No log file was fou
+nd\n";
chomp(my @status = readdir(DIR));
for (@status)
{
next if (($_ eq '.')||($_ eq '..'));
print "$_ : ";
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$m
+time,$ctime,$blksize,$blocks) = stat( $target_dir."\\".$_);
print "$mtime\n";
}
}
else
{
print " : No ApplicationSynchronizer folder was detacted.\n";
+
}
print "\n************************\n";
}
close (LST);
The script obtains the date stamp of the files and displays it.
It works fine, but what I want to do is to select the most recent file. For which I am not sure how to do in simple few steps (I suppose I can but it will be quite a long code).
So what I need is something like (below is all wrong because I don't know how to do it but it looks like something I have seen else where)
sort{$a <=>comp <=> $b} #this is wron but it looks like something I ha
+ve seen
Can somebody please enlighten me.
Thanks
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.