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

Re: [MacPerl] Problems with the "-x" file tests



Bill Hutten <bhutten@cochran.com> writes:
}I'm having a problem that's almost certainly attributable to my 
}stupidity, and i'd appreciate the lists' help:
}
}...given the following:
}
}
}foreach $item (@list) {
}	if (-d $item) {
}		print "directory: $item\n";
}	}else{
}		print "$item\n";
}	}
}}
}
}...where we have a list of files & directories in @list, why does the 
}"-d" test never evalate to true?  If I use "-e" to test for existance it 
}never works either, leading me to conclude that 1) those operators are 
}broken or b) i'm an idiot.
}
}
}...anyone care to tell me if it's (a) or (b)?  ...and yes, this is my 
}first day with Perl.

It's not a), they do work.  So the question becomes how did you generate @list, and what directory does MacPerl think it's in when you run through @list?  (If you're in the wrong directory, it's not likely to do what you expect.)  Try
putting print `pwd`; just before the foreach loop and see what it says.  In fact, just to be on the safe side, put this line in:

print scalar(@list)." ".`pwd`;

just before the foreach loop.  The scalar(@list) tells you how many items are in @list, and the `pwd` tells you what directory MacPerl is looking at.


}
}
}
}thanks
}
}- bill
}
}
}----------------------------------------------
}Bill Hutten db+www         bhutten@cochran.com
}Cochran Interactive
}
}
}
}***** Want to unsubscribe from this list?
}***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch


---
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@pjstoaster.pg.md.us



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch