Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2016-10-26 06:19 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (336 votes). Check out past polls.