On 4/18/02 5:50 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> I have another gotcha though more to do with processing file info:

> the file tests ( '-f','-d' et al) which are emulated under MacPerl
> don't work in OSX using HFS+ disks (at least for me :-))
> 


???  Works for me -

#!/usr/bin/perl

opendir TARGETDIR, "." || die "Cannot Read: $!";
@allfiles = grep !/^\./, readdir TARGETDIR;
closedir TARGETDIR;
    
foreach $target (@allfiles) {
    print "Looking at $target, I see it ";
    print "is a File " if (-f $target);
    print "is a Directory " if (-d $target);
    print "and is a Binary " if (-B $target);
    print "and has Size " if (-s $target);
print "\n";
}

=pod

The file area looks like this:

268300 drwxr-xr-x   8 sneex  staff   228 Apr 18 06:18 .
 74268 drwxr-xr-x  94 sneex  staff  3152 Apr 18 06:13 ..
548487 -rw-rw-rw-   1 sneex  staff  6148 Feb 10 12:39 .DS_Store
744412 -rw-r--r--   1 sneex  staff   566 Apr 18 06:20 FD_Stat.perl
744409 -rw-r--r--   1 sneex  staff     0 Apr 18 06:17 I'm a Directory
744410 -rw-r--r--   1 sneex  staff     0 Apr 18 06:17 I'm a File
268304 drwxr-xr-x  13 sneex  staff   398 Oct 30 22:42
Msql-Mysql-modules-1.2219
744411 drwxr-xr-x   2 sneex  staff   264 Apr 18 06:17 No, I am a Directory

-r      File is readable by effective UID/GID
-w      File is writable by effective UID/GID
-x      File is executable by effective UID/GID
-o      File is owned by effective UID
-R      File is readable by real UID/GID
-W      File is writable by real UID/GID
-X      File is executable by real UID/GID
-O      File is owned by real UID
-e      File exists
-z      File has zero size
-s      File has nonzero size (returns size)
-f      File is a plain file
-d      File is a directory
-l      File is a symbolic link
-p      File is a named pipe (FIFO)
-S      File is a socket
-b      File is a block special file
-c      File is a character special file
-t      Filehandle is opened to a tty
-u      File has setuid bit set
-g      File has setgid bit set
-k      File has sticky bit set
-T      File is a text file
-B      File is a binary file (opposite of -T)
-M      Age of file in days when script started
-A      Same for access time
-C      Same for inode change time (not creation)

=cut


[localhost:~/Install] sneex% perl FD*

Looking at FD_Stat.perl, I see it is a File and has Size
Looking at I'm a Directory, I see it is a File and is a Binary
Looking at I'm a File, I see it is a File and is a Binary
Looking at Msql-Mysql-modules-1.2219, I see it is a Directory and is a
Binary and has Size
Looking at No, I am a Directory, I see it is a Directory and is a Binary and
has Size 


???
_Sx____________________
  ('>    -Sx- IUDICIUM
  //\   Have Computer -
  v_/_    Will Hack...


Reply via email to