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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.