Earth to Brain!! Sorry I think I temporarily forgot the 'sort' function, Marty ----- Original Message ----- From: "Martin Moss" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, June 04, 2003 9:04 PM Subject: [Perl-unix-users] Sorting Flat list of Module Names into Tree structure
> Hi All, > > Wondering if anybody has an 'efficient' Hat on today? > > I Have a Hash who's Key's are all 'Module Names'. > e.g. > > Foo=>1 > Foo::Bar=>1 > Foo::Bar::Poo=>1 > Foo::Beer=>1 > Foo::Beer::Nuts=>1 > Foo::Beer::Nuts::Hmmm=>1 > Foo::Bar::AgainHmmm=>1 > > What I want to do is to turn this hash into a Hierarchical Hash based upon > the Module Name Structure e.g. > > { > 'Foo=>{ > 'Foo::Bar'=> { > 'Foo::Bar::Poo'=>1, > 'Foo::Bar::AgainHmmm=>1, > }, > 'Foo::Beer=>{ > 'Foo::Beer::Nuts=>{ > > Foo::Beer::Nuts::Hmmm=>1, > }, > } > } > } > > The Strucuture can be unlimited in depth. > Can anybody suggest an efficient Solution? > Is it possible to use grep on the hash Keys? > > My Other question is, If The Original Hash was an @array could the structure > be built on the fly, or do I need to know all the hash keys in advance? > (I ask this coz I generate the original hash structure from an array (whilst > doing other processing) and wondered if I could tie it all in together) > > Regards > > Marty > > > _______________________________________________ > Perl-Unix-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs