Regarding the comments you placed in your output (which were very helpful):
<container type="folder" name="CCT023" expanded="True"> ######## nee
+d to get foldername CCT not filename
(and likewise for the other two input files). This is happening because you are using the variable "$subdirlevel2" which is being set to the file name (minus the extension); you should set that to the appropriate directory name instead.
</container> ####################### not required
Your comment there is incorrect. You have opened two "container" tags, one nested inside the other, so you need to close tags, one after the other, to complete the structure.
Have you tried stepping through your code with the perl debugger? If you haven't learned to use the debugger yet, it's time to learn now. It's really very simple. (The full man page for it is here: perldebug, but you might want to start with perldebtut.) Set a breakpoint in your subroutines, and step through the lines of code in each one, checking the values that get assigned to variables, and what the various modules and functions are returning.
Also, take a closer look at how the sample code I suggested in my earlier reply is handling the information made available by File::Find. Read the man page for File::Basename more carefully. You might also need to consider what will happen when your program has to cover a different pattern of directory nesting.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||