in reply to Re^2: Problem with directory path checking
in thread Problem with directory path checking
Note that permissions on all of the ancestor directories also matter.
To aid in diagnosing the problem, you might want to do something like the following:
my $dir = '/home/bla/public_html/blabla'; my $isDir = -d $dir; if( $isDir ) { print "Found directory: $dir\n"; } elsif( defined $isDir ) { print "Found non-directory: $dir\n"; } else { print "Can't stat($dir): $!\n"; }
That way you can distinguish between "permission denied" vs "no such file/dir" vs something more exotic. The next step narrows down the source of the problem:
use File::Basename 'dirname'; my $dir = '/home/bla/public_html/blabla'; my $isDir; while( ! defined $isDir ) { my $isDir = -d $dir; if( $isDir ) { print "Found directory: $dir\n"; } elsif( defined $isDir ) { print "Found non-directory: $dir\n"; } else { print "Can't stat($dir): $!\n"; } last if '/' eq $dir; $dir = dirname( $dir ); }
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Problem with directory path checking ($!)
by Anonymous Monk on Jan 12, 2012 at 07:32 UTC |