our KEY_LIST => [ qw/ thumbnailForWebsite thumbnailForForums1 thumbnailForForums2 hotlinkForForums1 hotlinkForForums2 hotlinkForWebsite showImage directLinkToImage / ]; sub get { my $self = shift; my $key = shift; # could grep @{&KEY_LIST} here too to check for valid key return exists $self->{liste}->{$key} ? $self->{liste}->{$key} : undef; } # this could be left the same or changed to this: sub get_all { my $self = shift; return { map { $_ => $self->{liste}->{$_} } @{&KEY_LIST} }; } # note: could also replace get_all() with get() or get('all') # and note that the loop in upload() becomes just: foreach( @{&KEY_LIST} ){ ... }