in reply to Re: creating the hierarchy pattern from the input file
in thread creating the hierarchy pattern from the input file
Trouble is rather that you might end with a bug depending on input if you try increment a hashref.
I would prefer
DB<41> $ref= $tree DB<42> x @keys = split /@/,'a@b@c' 0 'a' 1 'b' 2 'c' DB<43> $ref = ($ref->{$_}//={})for @keys DB<44> x $tree 0 HASH(0xaa630cf0) 'a' => HASH(0xaa6204a0) 'b' => HASH(0xaa6719b0) 'c' => HASH(0xaa75baa0) empty hash DB<45>
DB<45> x @keys = split /@/,'a@b@d' 0 'a' 1 'b' 2 'd' DB<46> $ref= $tree <= ($ref->{$_}//={})for @keys DB<48> x $tree 0 HASH(0xaa630cf0) 'a' => HASH(0xaa6204a0) 'b' => HASH(0xaa6719b0) 'c' => HASH(0xaa75baa0) empty hash 'd' => HASH(0xaa672e30) empty hash DB<49>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|