Hi Shekar, Appreciate your help, you saved me a lot of time !
I applied your loop and it works fine. Apologies i couldn't post my final program due to our internal system restriction.hence i have used test data here. @match = ("6c7b00", "6d7b00", "6d9d8f", "6c6863", "6e6632"); %abc = ('6c' =>'device1', '6d'=> 'device5', '6e'=> 'device3', '6g'=>'device9'); foreach my $element(@match) { print $element."=>".$abc{substr($element, 0, 2)}."\n"; } if i understand right, the loop scrolls through the array elements and prints the hash value if it matches the first 2 character. pls correct me if am wrong, Thanks Sj On Fri, Oct 5, 2012 at 7:23 AM, Shekar <c.shekar1...@gmail.com> wrote: > Would this help. > > @match = ("6c7b00", "6d7b00", "6d9d8f", "6c6863", "6e6632"); > > > %abc = ('6c' =>'device1', '6d'=> 'device5', '6e'=> 'device3', > '6g'=>'device9'); > > foreach my $element(@match) { > > > print $element."=>".$abc{substr($element, 0, 2)}."\n"; > > > } > > -- > Shekar > > > On Thu, Oct 4, 2012 at 10:14 PM, Lawrence Statton <lawre...@cluon.com>wrote: > >> On 10/04/2012 11:26 AM, jet speed wrote: >> >>> Hi All, >>> >>> >>> I am trying to find the array elements in hash, if it matches then print >>> the hash value. Please help me to achieve this. >>> >>> Note: array elements matches the first 2 characters of the hash keys. >>> >>> >>> @match = ("6c7b00", "6d7b00", "6d9d8f", "6c6863", "6e6632"); >>> >>> >>> %abc = ('6c' => device1, '6d'=>device5, '6e'=>device3, '6g'=>device9); >>> >>> >>> Appreciate your help with this. >>> >>> Thanks >>> Sj >>> >>> >> What have you written thus far? >> >> >> >> >> >> -- >> To unsubscribe, e-mail: beginners-unsubscr...@perl.org >> For additional commands, e-mail: beginners-h...@perl.org >> http://learn.perl.org/ >> >> >> >