in reply to store parent child relation
I've made a wide exploration of the tree, without recursion, the result is akin the one you've shown on your post
hope that helps...#!/usr/bin/perl @ini_array = getarr("1"); @final_array = (1); while (@ini_array) { @aux = (); push @final_array, @ini_array; map { push @aux, getarr($_) } @ini_array; @ini_array = @aux; } sub getarr { $fl = shift; @sublist=(); open(A,"$fl.txt") or die "Can't open $fl.txt"; while (<A>) { chomp; push @sublist, $_; } close A; return @sublist; } print "final: @final_array\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: store parent child relation
by Anonymous Monk on May 18, 2006 at 08:41 UTC |