Not sure how to do this in Perl. I print out the contents of a directory (unix) by doing
my $searchpath="/usr/storage"; print "Here are the contents of the chosen search path\n"; sle +ep 2; my @files = <$searchpath/*>; foreach my $file (@files) { print $file . "\n"; }
However if the contents of $searchpath/* is itself a set of sub-directories I wish to print the contents of those as well (displaying the full path for each directory, but not the files within it) down the tree until no more sub-directories exist. I don't won't know the level of recursivness until the code is run.

e.g.

/usr/storage (top level directory) location1 (this is a directory) location2 (this is a directory) afile1 (this is a file) afile2 /usr/storage/location1 afile2 afile3 location3 (this is a directory) /usr/storage/location2 afile /usr/storage/location1/location3 afile afile1 afile2
Any help appreciated .

In reply to Recursive directory listing by Anonymous Monk

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.