sub somefunc { my($self, $context) = @_; return 1 # assumed just OK, but no further processing unless $self->{config}{key1} && $self->{config}{key1}{context} && $self->{config}{key1}{context}{$context} && $self->{config}{key1}{context}{$context}{form}; my $form = $self->{config}{key1}{context}{$context}{form}; # I can work with $form ... }