Hi Monks,

I have a directory structure like shown below

-------------------------------------------------
Directory: /proj/newdata/ Files: alpha.seq, beta.pm, gamma.txt Sub Directories: dog, cat Sub-Directory:dog Files: batman0.seq, batman1.txt Sub Directories: D1, D2 Sub-Directory: D1 Files: joker0.seq, joker1.pm Sub Directories: C0 Sub-Directory: C0 Files: file0.seq, file1.pm, file.txt Sub-Directory:cat Files: man0.seq, man1.txt Sub Directories: D3, D4 Sub-Directory: D3 Files: jok0.seq, jok1.pm Sub Directories: C1 Sub-Directory: C1 Files: f0.seq, f1.pm, f.txt
---------------------------------------------------

Now I want a perl script which can take the input directory name '/proj/newdata' and find all the files that end only with .seq and .pm and print them according to their directory structure like this:

RESULT: -------------------------------------------------

Group: /proj/newdata { File: alpha.seq (/proj/newdata/alpha.seq) File: beta.pm (/proj/newdata/beta.pm) Group: dog { File: batman0.seq (/proj/newdata/dog/batman0.seq) Group: D1 { File: joker0.seq (/proj/newdata/dog/D1/joker0.seq) File: joker1.pm (/proj/newdata/dog/D1/joker1.pm) Group: C0 { File: file0.seq (/proj/newdata/dog/D1/C0/file0.seq) File: file11.pm (/proj/newdata/dog/D1/C0/file1.pm) } #Group C0 } # Group D1 } # Group Dog Group: cat { File: man0.seq (/proj/newdata/cat/man0.seq) Group: D3 { File: jok0.seq (/proj/newdata/cat/D3/jok0.seq) File: jok1.pm (/proj/newdata/cat/D3/jok1.pm) Group: C1 { File: f0.seq (/proj/newdata/dog/D3/C1/file0.seq) File: f1.pm (/proj/newdata/dog/D3/C1/file1.pm) } #Group C1 } # Group D3 } # Group Cat } # Group /proj/newdata

-------------------------------------------------------

The words after "#" are comments and are not required.

Any help would be appreciated. I used File::Find and some other ways but could not crack the correct directory structuring printing and it's been some time I am working on this.

Thankyou

In reply to Traverse through directory structure and print in required format by newlearner

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.