http://www.perlmonks.org?node_id=559229


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.