I am trying to get the date stamps of multiple files on a win32
machine using the strftime function in a foreach loop.

For testing purpose, I take a single file and get the modification
time of it.  This works.

I then recycle my code and place it in a foreach loop.  This fails.

Error message is: 
Usage: POSIX::strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -
1, isdst = -1)

Here is my code:

#!/usr/bin/perl -w
use strict;
use Time::localtime;
use Date::Calc qw(:all);
use File::stat;
use POSIX qw(strftime);

#WORKS....
my $file = 'D:\BACKUPS\LOGS\S0000839.LOG';
my $s = stat($file) || die "Can't stat($file) $!\n";
my $modtime = strftime('%Y-%m-%d', localtime($s->mtime));
print($modtime);


#FAILS.....
my $dblogfile_dir = 'D:\BACKUPS\LOGS';
opendir(DH, $dblogfile_dir) or die "could not open directory: $!";
my @files = grep(!/^\.\.?$/, readdir(DH));

foreach my $member (@files) {
    my $file = "$dblogfile_dir\\$member";
    my $s = stat($file) || die "Can't stat($file) $!\n";
    my $modtime = strftime('%Y-%m-%d', localtime($s->mtime));
    print($modtime);
}
closedir(DH);

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to