From 612847f81d74f641b49aa93b88b567318ba0fcfa Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 30 Jan 2003 01:29:44 +0000 Subject: (helper_separator_tree_to_tree): this new function helps transforming a flag {list} to a tree, using {separator} --- perl-install/interactive.pm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'perl-install/interactive.pm') diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm index 5285781ab..c32553a88 100644 --- a/perl-install/interactive.pm +++ b/perl-install/interactive.pm @@ -425,4 +425,30 @@ sub wait_message { sub kill {} + + +sub helper_separator_tree_to_tree { + my ($separator, $list, $formatted_list) = @_; + my $sep = quotemeta $separator; + my $tree = {}; + + each_index { + my @l = split $sep; + my $leaf = pop @l; + my $node = $tree; + foreach (@l) { + $node = $node->{$_} ||= do { + my $r = {}; + push @{$node->{_order_}}, $_; + $r; + }; + } + push @{$node->{_leaves_}}, [ $leaf, $list->[$::i] ]; + (); + } @$formatted_list; + + $tree; +} + + 1; -- cgit v1.2.1