use strict; use warnings; our $hosts={}; $hosts->{hosta}->{ip}=192.168.1.1; $hosts->{hostb}->{ip}=192.168.1.2; $hosts->{hostc}->{ip}=192.168.1.3; our $services={}; $services->{1}->{ID}=1; $services->{1}->{name}='servicea'; $services->{1}->{startup}=sub { print "--> start service 1\n" }; $services->{2}->{ID}=2; $services->{2}->{name}='serviceb'; $services->{2}->{startup}=sub { print "--> start service 2\n" }; $hosts->{hosta}->{services}->{1}=$services->{1}; $hosts->{hostb}->{services}->{1}=$services->{1}; $hosts->{hostc}->{services}->{2}=$services->{2}; print "--> type hostname\n"; my $host=; chomp($host); die "host unknown " unless exists $hosts->{$host}; print "--> which service do you want to use? (Type ID)\n"; while (my ($ID, $service) = each %{$hosts->{$host}->{services}}) { print "- ID $ID, name ".$service->{name}."\n"; } my $ID=; chomp($ID); die "service unknown " unless exists $hosts->{$host}->{services}->{$ID}; &{$hosts->{$host}->{services}->{$ID}->{startup}}; exit; ---> output: --> type hostname hosta --> which service do you want to use? (Type ID) - ID 1, name servicea 1 --> start service 1