>> if($ARGV[0] =~ /(.*):/) { $dir = $1 } >> opendir(HERE, "$dir"); >> @alltitles = readdir(HERE); >> closedir(HERE); >> foreach $title (@alltitles) { >> if (-d $title) {print "$title \(folder\)\n";next;} >> if (-B $title) {print "$title \(binary\)\n";next;} >> print "$title\n"; >> } >From Andrew M Langmead: ~~~~~~~~~~~~~~~~~~~~~~~ >The issue is that opendir() does not pre-pend a full pathname to the >list of files that it returns, and the filetest operators are assuming >the current directory if no pathname is specified. >if ( -d "$dir:$title") { print ....} >would probably do what you want. No -- MacPerl regards that (and also 'if(-d $dir$title) as a syntax error. >With your current code, you might also notice that ( -e $title) would >return false. Yes -- in fact you can print all the files in the directory correctly complete with the nonsense message "this file does not exist". >From Hal Wine: ~~~~~~~~~~~~~~ >MacPerl (or Perl) doesn't loose the ability. You asked it to check the >type of files in the current directory, regardless of where the file >reside! Either change the current directory beforehand: > chdir( $dir ) || die( "Can't cd to '$dir': $!\n" ); > opendir( HERE, ':' ).... >or use the given directory in the file tests: > if (-d "$dir$title")... chdir() before opendir() does the trick. I take your point you should tell Perl where to look, but it still seems odd to me it can 'see' the file itself, but not the 'file _type_' if you don't. To both Andrew and Hal -- many thanks for your replies and comments. Alan