문제

-e  File exists.

is there one for directory exists? because i didnt see it on http://perldoc.perl.org/functions/-X.html

Or what would be a best way to test it?

next unless (-e $dir . "/dirname");             -e only for file so doesnt work

I am trying to avoid doing opendir and grep to find the dirname because it seems to be overkill.

updated question:
does perl concat $dir . "/dirname" before doing the -e or -d check?

도움이 되었습니까?

해결책

Use the -d test to see if the given path is a directory. In that case, -e will also return true, because that tests for existence of some filesystem object.

To see if a path points to a plain file (no directory, no symlink, no special file), use -f.

So you want:

-d "$dir/dirname" or next;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top