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

Re: Reading an arbitrary hierarchy into a hash tree

by maverick (Curate)
on Aug 07, 2001 at 05:22 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://102665]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-20 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found