Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
i guess, this will not exist, because it is actually a combination of querying data from a database and displaying the result.

That is one way of evaluating the problem, however it is possible to 'rethink' the situation if you strip away pre-existing paradigms, methodologies, and ask the following:

Given this:

sitcom/simpsons/homer/simpson sitcom/simpsons/ned/flanders sitcom/flintstones/fred/flintstone sitcom/flintstones/wilma/flintstone sitcom/flintstones/barney/rubble gameshow/price is right/bob/barker gameshow/jeopardy/alex/trebek

What can I use to transform it into this?:

$dataroot = { 'gameshow' => { 'price is right' => [ { 'lname' => 'barker', 'fname' => 'bob' } ], 'jeopardy' => [ { 'lname' => 'trebek', 'fname' => 'alex' } ] }, 'sitcom' => { 'simpsons' => [ { 'lname' => 'simpson', 'fname' => 'homer' }, { 'lname' => 'flanders', 'fname' => 'ned' } ], 'flintstones' => [ { 'lname' => 'flintstone', 'fname' => 'fred' }, { 'lname' => 'flintstone', 'fname' => 'wilma' }, { 'lname' => 'rubble', 'fname' => 'barney' } ] } };

The key consideration here is a simple question of transforming the flat 'row-based' representation into a 'nested representation'. This does not necessarily involve a database at all. Nor does it necessarily involve 'displaying' anything (unless you count using Data::Dumper to show the output for illustrative purposes only).

=oQDlNWYsBHI5JXZ2VGIulGIlJXYgQkUPxEIlhGdgY2bgMXZ5VGIlhGV

In reply to Re^2: tree-oriented query against table-oriented data by dimar
in thread tree-oriented query against table-oriented data by dimar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-18 09:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found