in reply to Re: A little help w/ stat() por favor...
in thread A little help w/ stat() por favor...

Thanks for the fast reply. When I tried

$mtime = stat($files)[9];

I got syntax errors and it wouldn't work.

$mtime = -M $files;

printed out 1's next to each file.

Any other suggestions?

Replies are listed 'Best First'.
Re3: A little help w/ stat() por favor...
by blakem (Monsignor) on Jan 11, 2002 at 06:48 UTC
    Oops, sorry... that should have been:
    $mtime = (stat($files))[9];

    -Blake

      Thanks again Blake.. Still just giving me 1's. I tried
      $size = (stat($files))[7];
      because i definetly know the size of the file and it still gave me 1's. I dont get this. I thought this would be something pretty easy for me to figure out.
        Is $files a relative path? I think stat needs the full path to the file. Try something like this:
        #!/usr/bin/perl -wT use strict; my $dir = "/var/www/html/file"; my @files; opendir (FILE,$dir) || die "'$dir' $!"; @files = grep {-f "$dir/$_"} readdir (FILE); closedir (FILE) || die $!; foreach my $file (sort(@files)) { my $mtime = (stat("$dir/$file"))[9]; print "$mtime => $file\n"; };

        -Blake

      Still giving me 1's. I tried with $size and $uid. All give me just the number 1