Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: looping logic error while printing output from folder/flie content

by graff (Chancellor)
on Dec 18, 2012 at 08:19 UTC ( [id://1009307]=note: print w/replies, xml ) Need Help??


in reply to Re^3: looping logic error while printing output from folder/flie content
in thread looping logic error while printing output from folder/flie content

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 </container> ...
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.

Replies are listed 'Best First'.
Re^5: looping logic error while printing output from folder/flie content
by Vijay81 (Acolyte) on Dec 18, 2012 at 15:41 UTC

    Thanks Graff. Now I have installed pkdb module after reading the point which you said in pervious reply and I can do the debugging line by line.

    On this point : "You might also need to consider what will happen when your program has to cover a different pattern of directory nesting."

    Even i was thinking this, what ever i tried to script is now only for pre defined set of directory structure, which is very wrong way. Can you please advise how can make script more generic one so that don't need to depend on directory pattern

    Many Thanks
      The code I posted above is one way to handle variation in the directory structure. You might need to tweak it to get the kind of xml layout that you want.
      A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1009307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-24 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found