my $addr = $xml->{config}{server}->('name','=~','sahara')->{address}[0] ; ## the same, it just get the first: my $addr = $xml->{config}{server}->('name','=~','sahara')->{address} ; ## return all the addresses: my @addrs = $xml->{config}{server}->('name','=~','sahara')->{address} ; ## Get the first server node: my $server = $xml->{config}{server}[0] ; ## or without [0], since wihtout always return the 1st: my $server = $xml->{config}{server} ; ## Or get the server that have a specific name, ## when you don't know the order: my $server = $xml->{config}{server}->('name','eq','sahara') ; my $addr = $server->{address} ; ## Print the content: print "Server content: $server\n" ; __DATA__
10.0.0.101
10.0.1.101
10.0.0.102
10.0.0.103
10.0.1.103