[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Problem with -l file test



I've been working my way through MPPE, and I'm pretty new at this,
apologies in advance if I overlooked something obvious.  I'm working on a
script to use as a droplet that will take either a folder or files and do
"stuff".  I want to skip aliases that might be in the directories.  While
using the file tests for file, directory and alias, aliases are reported as
files, whether I test the filename or the filespec.   It almost looks as
though it is resolving the alias before it is doing the file test.   I
could screen for aliases using Applescript, but I'd rather "just use
Perl".....

I've attached the code and the output below so wiser eyes can tell me where
I'm going wrong.  Using a PowerBook G3 (1999), OS 8.6.

#!perl -w
use strict;

my($item, $fsItem);
#create an alias here to test
symlink('Zoot:Trash', 'Zoot:Trash alias');
$item = 'Zoot:Trash alias';
$fsItem = MacPerl::MakeFSSpec($item);

if (-f $item) {
		print ("$item is a file\n");
	} elsif (-d $item) {
		print ("$item is a directory\n");
	} elsif (-l $item) {
		print ("$item is an alias\n");
	} else {
		print ("$item is not a directory, file, or alias\n");
	}

if (-f $fsItem) {
		print ("$fsItem is a file\n");
	} elsif (-d $fsItem) {
		print ("$fsItem is a directory\n");
	} elsif (-l $fsItem) {
		print ("$fsItem is an alias\n");
	} else {
		print ("$fsItem is not a directory, file, or alias\n");
	}

#Here's the output
Zoot:Trash alias is a directory
FFFF00000002:Trash is a directory

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org