DeusVult has asked for the wisdom of the Perl Monks concerning the following question:
Is a directory a file? Do the file operators of perl treat them that way? For example,
my $dir = "directory"; # this dir exists my $no_dir = "no.such.directory"; # this one does not print "$dir exists" if ( -e $dir ); print "$dir is a directory" if ( -d $dir ); print "$no_dir exists" if ( -e $no_dir ); print "$no_dir is a directory" if ( -d $no_dir );
My first question is with the first line. Will perl consider $dir to exist and do so for all platforms (that's the important part, otherwise I'd just test it, but I need access to the inner secrets here)?
Secondly, is it defined to check if a meaningless word is a directory? Will the last line cause no errors (again, on all platforms)?
And finally, on a related note, what happens if I write
use File::Path; rmtree( [$name], 0, 0 );
and $name is the name of a file, not a directory?
Thanks in advance.
Some people drink from the fountain of knowledge, others just gargle.
Back to
Seekers of Perl Wisdom