Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Reading an arbitrary hierarchy into a hash tree

by maverick (Curate)
on Aug 07, 2001 at 05:22 UTC ( #102665=note: print w/replies, xml ) Need Help??


in reply to Reading an arbitrary hierarchy into a hash tree

#!/usr/bin/perl use strict; use Data::Dumper; my $struct; my $depth = -1; while(<DATA>) { my $d = $_ =~ tr/\t//; $struct .= "},\n" x ($depth-$d+1) . "$_ => {"; $depth = $d; } $struct = eval "{" . $struct . "}" x ($depth+2); print Dumper $struct; __DATA__ here is my shot at doing this Since perl is very good at string manipulation this is about the sickest way I could think to make this work out Perhaps this is not the best way but I like it

/\/\averick

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://102665]
help
Chatterbox?
[stevieb]: The people back then (~2000) are the same people now, but with much more experience. I'm appreciative that I fell into the Perl rabbit hole.
[stevieb]: Coding circles around Python devs, showing how unit tests should be done, enabling easy access to everything, learning basic C to wrap for direct hardware access... I am thankful.
[stevieb]: I'm in an appreciative mood. Thank you fellow Monks, for all I know, and for the knowledge which I can pass on

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2017-02-25 01:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (364 votes). Check out past polls.