Other Monks have given you the answer to your question and advice on how to access the documentation. This is to bring to your attention, should you be working in a *nix environment, the fact that a symbolic link to a directory will also give a positive with the -d file test operator. If you wish to distinguish between directories and symbolic links that point to directories you will also have to use the -l file test.

knoppix@Microknoppix:~/data$ mkdir mydir knoppix@Microknoppix:~/data$ ln -s mydir mylink knoppix@Microknoppix:~/data$ ls -l total 4 drwxr-xr-x 2 knoppix knoppix 4096 Aug 13 15:52 mydir lrwxrwxrwx 1 knoppix knoppix 5 Aug 13 15:52 mylink -> mydir knoppix@Microknoppix:~/data$ perl -E ' > say q{-} x 40; > foreach my $thing ( qw{ mydir mylink } ) > { > say > qq{-d test says $thing is }, > -d $thing > ? q{} > : q{not }, > q{a directory}; > say > qq{-l test says $thing is }, > -l $thing > ? q{} > : q{not }, > q{a symlink}; > say q{-} x 40; > }' ---------------------------------------- -d test says mydir is a directory -l test says mydir is not a symlink ---------------------------------------- -d test says mylink is a directory -l test says mylink is a symlink ---------------------------------------- knoppix@Microknoppix:~/data$

I hope this is helpful.

Cheers,

JohnGG


In reply to Re: What are -d and -f for? by johngg
in thread What are -d and -f for? by tej

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.