in reply to Generating recursive hash

If you meant a different kind of recursive hash, you could try:

#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; my (@child_list, %Nodes, $id, $data, $parent); while (<DATA>) { @{$Nodes{$id}}{'ID','Data','Parent'} = (($id,$data,$parent)=split +/\s+/,$_); $Nodes{$parent}{Children}{$id} = $Nodes{$id}; push @child_list, $id; } delete $Nodes{$_} for @child_list; print Dumper(\%Nodes); + __DATA__ 1 data 0 2 data 1 3 data 1 4 data 3 5 data 4

...roboticus