in reply to Re-ordering data branches in a [Tree::DAG_Node] tree
Fun little problem :)
#!/usr/bin/perl # http://perlmonks.org/?node_id=1213391 use strict; use warnings; my @test_data = ( 'a', # ' b', # ' e', # ' f', # ' g', # ' c', # ' d', # 'h', # ' i', # ' j', # ); my $onestring = join '', map "$_\n", @test_data; print $onestring, "=" x 60, "\n"; print group($onestring); sub group { my @groups; push @groups, "$1" . group("$3") while $_[0] =~ /(( *).*\n)((?:\2 +. +*\n)*)/g; join '', sort @groups; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Re-ordering data branches in a [Tree::DAG_Node] tree
by AnomalousMonk (Archbishop) on Apr 23, 2018 at 04:44 UTC | |
by tybalt89 (Monsignor) on Apr 23, 2018 at 09:15 UTC |