Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Parsing a Tree to a Table.

by BrowserUk (Pope)
on Dec 10, 2013 at 10:21 UTC ( #1066409=note: print w/replies, xml ) Need Help??

in reply to Parsing a Tree to a Table.

For fun.

#! perl -slw use strict; my @a; my $last = 0; while( <DATA> ) { m[(^[^A-Z]+)?([A-Z]+)] or next; my $l = length( $1//'' ); if( @a and $l <= $last ) { print join "\t", @a; pop @a for 1 .. ($last-$l+3)/3; } push @a, $2; $last = $l; } print join "\t", @a; __DATA__ A | |--B | | | |--C | | | |---PQR | |---XYZ |--D | | | |---LMN |---XYZ

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1066409]
and the radiator hisses contentedly...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2017-01-17 19:18 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (158 votes). Check out past polls.