"Scott, Deborah" wrote:
> But one directory contains files with the exact same title, except for the
> date (which is NOT written to sort correctly).
> Examples:
> "Daily Mailer 2103"(this is the Mailer for Feb 1, 2003), "Daily Mailer
> 112102"(this is the Mailer for November 21, 2002), "Daily Mailer 21103"
> (this is the Mailer for Feb 11, 2003), etc.
[snippet from Win 2000 dir command output]:
03/20/2003 02:29p 616 Address.pm.$$$
12/28/2002 11:02p 646 AndIPs.pl
12/28/2002 11:01p 776 AndIPs.pl.$$$
01/05/2003 09:37a 61 BaseTest.pl
01/05/2003 09:35a 60 BaseTest.pl.$$$
12/29/2002 08:28p 2,028 BenchmarkTest.pl
12/29/2002 08:27p 2,027 BenchmarkTest.pl.$$$
[/snippet]
So this:
#!perl-w
use strict;
use warnings;
# DOS-Windows specific. My need to reorder column values
# depending on OS version
open DIR_CMD, "dir | ";
my $junk ='';
$junk = <DIR_CMD> until $junk =~ /^ Directory of/;
$junk = <DIR_CMD>;
my @lines = <DIR_CMD>;
for (@lines) {
my ($date, $time, $size_or_dir_tag, $filename) = split /\s+/, $_, 4;
print $filename; # will still have newline
print " Modified at $time on $date. ";
if ($size_or_dir_tag =~ /DIR/) {
print "Directory\n";
} else {
print "Size = $size_or_dir_tag\n";
}
}
Produces output like:
Hi There,podner E:\d_drive\perlStuff>dircmd.pl
.
Modified at 08:10p on 03/31/2003. Directory
..
Modified at 08:10p on 03/31/2003. Directory
Address.pm
Modified at 02:29p on 03/20/2003. Size = 616
Address.pm.$$$
Modified at 02:29p on 03/20/2003. Size = 616
AndIPs.pl
Modified at 11:02p on 12/28/2002. Size = 646
...
BenchmarkTest.pl.$$$
Modified at 08:27p on 12/29/2002. Size = 2,027
choosing frame print_IE5.jpg # handles
long filenames smoothly
Modified at 01:22p on 10/19/2002. Size = 19,628
choosing frame print_NS4x.jpg
Modified at 01:35p on 10/19/2002. Size = 29,518
[snip]
Joseph
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]