Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
XP is just a number
 
PerlMonks  

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

by graff (Chancellor)
on Dec 18, 2012 at 08:19 UTC ( #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.


Comment on Re^4: looping logic error while printing output from folder/flie content
Select or Download Code
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.

        Thanks Graff. If am not asking too much. Can you please explain your script in details like what does each line do. so that after i understood correctly i can make the necessary changes

        Just add the comment on the side of each line. that will do for me please

        Many Thanks..

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-04-24 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (565 votes), past polls