sub children { my $self = shift; $self->{cached_children} ||= do { # find the children, and end up with (say) an array \@result; }; @{ $self->{cached_children} }; }