Re: "-e" and "-d" switches
by dragonchild (Archbishop) on Mar 24, 2005 at 13:47 UTC
|
-d checks to see if something is a directory. -e checks to see if something exists. q.v. Filetest operators for more info.
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] |
Re: "-e" and "-d" switches
by brian_d_foy (Abbot) on Mar 24, 2005 at 13:49 UTC
|
These are the file test operators (which are different from the command line switches that look the same). They're documented in perlfunc.
In short, -d tests if its argument is a directory, and -e tests if its argument exists.
In your code, it looks like the if() ensures that there is a true value for those hash keys and that the file or directory does not already exist. The next part probably creates them.
--
brian d foy <bdfoy@cpan.org>
| [reply] |
Re: "-e" and "-d" switches
by artist (Parson) on Mar 24, 2005 at 13:48 UTC
|
-d => If it is a directory
-e => If it exists | [reply] |
Re: "-e" and "-d" switches
by manav (Scribe) on Mar 24, 2005 at 14:14 UTC
|
As an addendum,
-d implies -e ,whereas
-e does not imply -d
| [reply] |
|
|
Not quite.
- A successful -d implies a successful -e.
- A failed -e implies a failed -d.
However ...
- A failed -d says nothing about the success/failure of -e
- A successful -e says nothing about the success/failure of -d
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] |
|
|
| [reply] |
|
|
|
|
|
|
|
|
|
|
-d implies -e
It was a positive implication.
! -e implies ! -d
is negative implication.
-e does not imply -d
probably should have been
-e does not necessarily imply -d
| [reply] |
|
|
| [reply] |
Re: "-e" and "-d" switches
by ambs (Pilgrim) on Mar 25, 2005 at 18:34 UTC
|
The '-x' switches (perldoc -f -x) test various file properties.
In your case, -d "filename" tests if "filename" is a directory. -e "filename" just checks if it exists. For example, -f "filename" will tell you if the file is a plainfile.
You can use these switches to get other information from files like age or last change.
Alberto Simões
Python's syntax succeeds in combining the mistakes of Lisp and Fortran.
I do not contrue that as progress.
-- Larry Wall
| [reply] |