On Nov 13, ZHAO, BING said:

opendir GOP, "SCRATCH/BACKUP" or die "cannot open directory SCRATCH/BACKUP:$!";
my @smm=grep{($_ ne ".") && ($_ ne "..")} readdir GOP;
foreach (@smm){
   my($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime,
        $mtime, $ctime, $blksize, $blocks) = stat($_);
   print $ctime;
} closedir GOP;


This piece of code WORKS when I point opendir GOP to the current directory. But it DOESN"T work when I point to the subdirectory SCRATCH/BACKUP within the current directory. It's tricky. And " print $_ " successfully prints out the files in SCRATCH/BACKUP dir.

It prints the NAME of the file. But that file doesn't exist in the current directory, it exists in the SCRATCH/BACKUP directory. You need to prepend the directory path to the filename:

  foreach (@files) {
    my $ctime = (stat "SCRATCH/BACKUP/$_")[10];
  }

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
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