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

Re: Parsing a Tree to a Table.

by oiskuu (Hermit)
on Dec 05, 2013 at 16:20 UTC ( #1065786=note: print w/replies, xml ) Need Help??


in reply to Parsing a Tree to a Table.

Why is the question on hold at SO? Looks like someones homework alright, but to reverse tree visualisation is a valid problem and potentially useful to someone. Anyway, I hoped there would be some extra neat solution, then spent ten minutes correcting one silly mistake after another. Almost a one-liner:

#! /usr/bin/perl -ln /\|\s*$/ or /.*?--(-?)|/, splice(@a,$+[0]/3), $1 ? print join "\t", @a +[0..2], $' : push @a, $';

Replies are listed 'Best First'.
Re^2: Parsing a Tree to a Table.
by choroba (Bishop) on Dec 10, 2013 at 01:34 UTC
    If I understand it correctly, it only works for the trees of depth 4, right?
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Well, it prints as it goes, so prior knowledge of max depth is needed. (Adding this as option is trivial.)

      Note that the problem description shows four output columns, and mentions large data.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1065786]
help
Chatterbox?
[marto]: good morning all, TCIF!

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2018-07-20 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (426 votes). Check out past polls.

    Notices?