Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: tree-oriented query against table-oriented data

by BrowserUk (Patriarch)
on Jul 04, 2006 at 22:57 UTC ( [id://559229]=note: print w/replies, xml ) Need Help??


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

Try this:

#! perl -slw use strict; use List::Util qw[ reduce ]; use Data::Dumper; my %data; while( <DATA> ) { my( $genre, $title, $fname, $lname ) = split '/'; $data{ $genre } = {} unless exists $data{ $genre }; $data{ $genre }{ $title } = [] unless exists $data{ $genre }{ $tit +le }; push @{ $data{ $genre }{ $title } }, { fname => $fname, lname => $ +lname }; }; print Dumper \%data; __DATA__ 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

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://559229]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2024-04-25 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found