Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

One thing that comes to mind right now is that you probably need to vet that data before you build algorithms that (necessarily...) rely upon your assumptions about it.   Specifically, do you know that the beginning of each and every line consists of 0 .. n ASCII "Tab" characters?   No spaces?   Do you know that the number of tabs in any line is no more than 1 greater than the number of tabs on the line preceding it?   Do you know that the first line contains no preceding tabs?

I suggest that the first part of your processing sequence should be a script whose sole purpose is to validate these assumptions about the data format.   Garbage in = Garbage out, and only the computer can tell you if it’s garbage.   If the data is not proved to be clean, then do not process it.   If the data is proved, then you can write algorithms based on any assumption that you have proved ... and yet, those subsequent algorithms should also be suspicious.   (Maybe the data wasn’t vetted this time, and an error has crept into the data from somewhere upstream ... only the computer is in a position to sound the alarm.)

Regular-expressions can easily handle these tests.   Each and every line must consist, anchored at the beginning of line, of zero-or-more tabs followed by a non-blank character.   If you extract the tabs in a group, the length of that string is of course the number of tabs.

In the future, I think that you definitely need to move this data to an alternate format, either XML or JSON.   Both of these are well-understood formats for representing hierarchical data, and in the case of XML, have formally-defined validation engines that do not require the writing of source-code.


In reply to Re: dynamic hash nesting by sundialsvc4
in thread dynamic hash nesting by karrakis

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!
  • 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, 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
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (12)
    As of 2014-10-23 20:10 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (128 votes), past polls