#!/usr/bin/perl use strict; my %hash = ( one => 'd$\vic', two => 'd$\daqq', three => 'c$\lol', four => 'd$\bom', five => 'd$\eef', six => 'd$\ff\logs' ); my %hoa = ( "array a" => [ "dd1", "dd2", "dd3", "dd4" ], "array b" => [ "gg1", "gg2", "gg3", "gg4" ], "array c" => [ "cc1", "cc2", "cc3", "cc4" ] ); my $input = ; chomp $input; if ((exists $hash{$input})) { foreach my $group(keys %hoa) { foreach (@{$hoa{$group}}) { if ($input = $_) { print "$input found in $group\n"; } } } }