... my $ua = LWP::UserAgent->new(); my $req = HTTP::Request->new('GET', $url); my $res = $ua->request($req); my $parser = XML::LibXML->new(); sub smart_match { my ($target, $param) = @_; if (ref $param eq 'Regexp') { return ($target =~ qr/$param/); } else { return ($target eq $param); } } my $xml = $parser->parse_string( $res->content() ); my @results; foreach my $dict ($xml->findnodes('//dict')) { my $key = $dict->getAttribute('key'); #next unless $key eq [qw( 'subnet', 'gateway', 'cidr', 'netmask' ) ]; next unless smart_match( $key, qw( subnet gateway cidr netmask ) ); print Dumper($key); push @results, {} if $key eq 'subnet'; my $value = $dict->findvalue('.//value'); $results[-1]{ $key } = "$value"; } print Dumper \@results;