#!/usr/bin/perl -w use strict; my @code_reference = qw(aaaa qqqqq 7781q 09888 wetrt); foreach my $code(@code_reference) { my $place = "http://mylocation?param=" . $code ; my $data = XML::TreePP->new(); my $all_data = $data->parsehttp( GET => $place ); # This will return a different value for each "@code_reference". It could be like: # "Value: AE" "Value: YY" "Value: C" "Value: P" "Value: PP" from my XML my $got_data=$all_data->{xml}->{code}->{"-data"}; # I have this hash, that I am trying to match lets say, if I got "Value: AE", I want to # find the value in the hash the match "AE" and print. my %wind_dir = ( 'Loc A' => 'AA,A,AE,AB,BB,EA,C', 'Loc B' => 'TT,T,AE,B', 'Loc C' =>'PP,P,PA', 'Loc D' =>'YY, TT,P,OP,QA' ); # It should print: Loc A found AE # Loc B found AE