Hi there again,

Any ideas?

  1. Take everything you've learned so far about working with Perl data structures and put it back in your newly-expanded toolbox. You'll never not need it, good job.
  2. Throw out most of your program so far.
  3. Set up a relational database for your data. It's time.

For the type of query that you want, being able to say select * from sub where subname = 'foo' order by date_modified desc limit 1 or similar simple SQL, is about 95% easier than trying to morph nested Perl data structures from one format into another.

I understand that you are working with a Mongo DB project, but I am not familiar with Mongo and it looks like you are storing nested structures and yet are not able to query them? If that's so, and you don't just need to read some more Mongo doc, set up an SQLite DB to crunch your data.

You can even set it up in memory in your process, populate it as you read in data, query it to analyze the data and make reports, and throw it away when the process is finished. I use exactly this technique to build nightly reports from a commercial website, reading in raw data from two or three places, building a temporary SQLite DB, and producing the reports from there.

The time it takes to figure out how to do that will not greatly exceed the time it takes to build up a huge ugly Perl program to make the same queries. Your code will be a tenth as long and 100 times more maintainable, readable, and robust.

Hope this helps!


The way forward always starts with a minimal test.

In reply to Re: Parsing output by 1nickt
in thread Parsing output by ovedpo15

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.