Fellow Perl Monks,

I come to you with a question that has been troubling me for the past hours. The problem itself is:

INPUT: (directory structure)

clocks001.jpg clocks002.jpg clocksvert001.jpg clocksvert002.jpg
clocksvertred001.jpg daisies001.jpg ...

I need to deduce category, subcategories and image numbers (I already solved that part) from the filenames without external database usages and then output it to a MySQL database through DBI.

The ideal output would consist of something like this;

clocks001.jpg -> category: clocks; subcats: null/null IM#: 001
clocks002.jpg -> category: clocks; subcats: null/null IM#: 002
clocksvert001.jpg -> category: clocks; subcats: vert/1 IM#: 001
clocksvert002.jpg -> category: clocks; subcats: vert/1 IM#: 002
clocksvertred001.jpg -> category: clocks; subcats: vert/1 red/1 IM#: 001 (vert is subcat 1 under clocks, red is subcat 1 under vert)

and so on.

Thanks for sharing your wisdom.

In reply to Directory Structure parsing by bscheiman

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.