in reply to Tree::Nary n00b has questions

First of all, please edit your node and put <code> tags around your code segments

Here is how your sub might look like (untested):

my $printsub = sub { my $node = shift; if (defined $node) { my $node_data = $node->{data}; if (defined $node_data and ref $node_data eq 'HASH') { print "node_data dir_name holds $node_data->{dir_name}\n"; print "node_data dir_vep holds $node_data->{dir_vep}\n"; } } return 0; }

I put the assignment of $node_data after the test whether $node is defined. Also there is no need to copy the hash so I changed it to a direct access of the node data. If you prefer the copy, use my %node_data = %{$node->{data}}; for the assignement instead. The test for definedness of $node should be unnecessary, the module won't call the routine without a node.

UPDATE: added defined-test of $node_data