in reply to Directory Structure parsing

Do you already know all the possible categories/subcategories? Is there a tree structure, or is it more free-form? Basically, we need to know how we can tell the end of the name of a category and the beginning of the name of a subcategory. If we knew, for example, that there were just categories, clocks, birds, and eels, and subcategories for each include vert and mood, we might have something like:
while(readdir(DIRHANDLE)) { if(s/^clocks//) { $thisline{category} = 'clocks'; } if(s/^birds//) { $thisline{category} = 'birds'; } ... if(! defined($thisline{category})) { die "No category defined!\n"; } if(s/^vert//) { $thisline{category} = 'vert'; } ... # And so on, for 2nd level subcategories. }
On the other hand, depending on how your categories and subcategories are, another approach might be better. If you can clarify your question, I can probably give you a better answer.

Replies are listed 'Best First'.
Re: Re: Directory Structure parsing
by bscheiman (Initiate) on Apr 01, 2003 at 23:16 UTC
    As a matter of fact, it's a free-form structure. The categories, subcategories, sub-subcategories (you get the idea) aren't known, that's part of why I need them to go into a DBI database. I know this isn't the best approach to do it. I also thought of using folders instead of names in the images: clocks/vert/red/001.jpg. But this would take some time since it's 250 megabytes worth of images. Oh well. I'll do whatever I have to do. Thanks again.