Re: Problem with STAT under Windows
- From: noreply@xxxxxxxxx (Gunnar Hjalmarsson)
- Date: Mon, 31 Mar 2008 16:11:34 +0200
anders wrote:
I tryed some testkod below, i like Perl to give med TIME for every
file,
But all variable just get blank, (i got filename).
You need to either alter the current directory using chdir(), or pass the full path to stat().
You may want to try this code:
use strict;
use warnings;
use Data::Dumper;
my $dir_to_open = 'f:/backupsv';
my $files = readFileList($dir_to_open);
print Dumper $files;
sub readFileList {
my $dir = shift;
opendir my $dh, $dir or die $!;
my @files = grep /\.txt/i, readdir $dh;
my %result;
foreach my $file ( @files ) {
@{ $result{$file} }{ qw/size atime mtime ctime/ } =
( stat "$dir/$file" )[7..10];
}
return \%result;
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- References:
- Problem with STAT under Windows
- From: Anders
- Problem with STAT under Windows
- Prev by Date: Re: algorithm/permute.pm
- Next by Date: parser using perl
- Previous by thread: Problem with STAT under Windows
- Next by thread: Uninitialized value in pattern match
- Index(es):
Relevant Pages
|
|