Given how that snippet is written, $newdir is in scope within the recursive function, so the function could just treat $newdir as an existing variable that has already been assigned a value.
But your question is unclear, because you don't show how dftree is being called. If you are creating some new directory in the CWD and don't want it to be involved in searches, just get a listing of things to search in the CWD before you create that directory. If there's some pre-existing directory in the CWD that you need to avoid, build a list of things to search in the CWD, remove that one item from the list, and handle the rest of the list.
If you're trying to exclude, say, "foobar" in the CWD, would you still be interested in handling anything called "foobar" at a lower level, or would you rather exclude everything called "foobar" no matter how deeply nested it might be?
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.