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.
|
---|
Replies are listed 'Best First'. | |
---|---|
(tye)Re: Subtleties of files and directories
by tye (Sage) on Mar 23, 2001 at 01:56 UTC | |
Re: Subtleties of files and directories
by clintp (Curate) on Mar 23, 2001 at 01:53 UTC | |
by premchai21 (Curate) on Mar 24, 2001 at 01:38 UTC | |
Re: Subtleties of files and directories
by SparkeyG (Curate) on Mar 23, 2001 at 01:48 UTC |
Back to
Seekers of Perl Wisdom