テキトウな質問にテキトウに答えた。
http://code.nanigac.com/forum/view/402
%tree = (A => ['B','G'], B => ['C', 'E'], C => ['D'], E => ['F'], G => ['H'], H => ['I','J'], J => ['K'], ); &search('A'); sub search { my @stack = @_; my @childs = @{$tree{$stack[-1]}}; if(@childs){ &search(@stack, $_) for @childs; }else{ print join("-", @stack) . "\n"; } pop @stack; }
air:perl mikeda$ perl tree.pl A-B-C-D A-B-E-F A-G-H-I A-G-H-J-K